Vous êtes sur la page 1sur 73

UML

Unified Modeling Language

Presented By-
Shah Imran Alam
CDAC- Mumbai
Why We Model ?

What is UML ?

The UML language is for


Visualizing
Specifying
Constructing
Documenting
Three major elements of UML

Building Blocks
Rules
Common Mechanism
Building Blocks Of UML

Things
Relationship
Diagrams
Four Kinds Of Things In UML

Structural Things
Behavioral Things
Grouping Things
Annotational Things
Structural Things (Nouns of UML)

Class
Interface
Collaboration
Use Cases
Active Classes
Components
Nodes
Structural Things (Cont…)

The nouns of UML models are usually the static


parts of the system in question.
Class - an abstraction of a set of things in the
problem-domain that have similar properties and/or
functionality. Window
origin
size
Notation: open()
close()
move()
display()
Structural Things (Cont…)

Interface - A collection of operations that specify the


services rendered by a class or component.

Notation:

CheckSpelling
Structural Things (Cont…)

Collaboration - a collection of UML building blocks


(classes, interfaces, relationships) that work
together to provide some functionality within the
system.

Notation: Chain Of
Responsibility
Structural Things (Cont…)

Use Case - an abstraction of a set of functions that the


system performs; a use case is “realized” by a
collaboration.

Process
Notation:
Order
Structural Things (Cont…)

Active Class - a class whose instance is an active


object; an active object is an object that owns a
process or thread (units of execution)

Notation: eventManager
Structural Things (Cont…)

Component - a physical part (typically manifests itself


as a piece of software) of the system.

DML_Parser.C
Notation:
Structural Things (Cont…)

Node - a physical element that exists at run-time and


represents a computational resource (typically,
hardware resources).

PrintServer
Notation:
Behavioral Things (Verbs of UML)

Interaction
Static machine
Behavioral Things (contd)

Interaction
The verbs of UML models; usually the dynamic
parts of the system in question.
some behaviour constituted by messages exchanged
among objects; the exchange of messages is with a view to
achieving some purpose.

Parse
Notation:
Behavioral Things (contd)

State machine
A behavior that specifies the sequence of “states” an
object goes through, during its lifetime. A “state” is a
condition or situation during the lifetime of an object
during which it exhibits certain characteristics and/or
performs some function.

Engine
Notation: Idling
Grouping Things (Packages)

The organizational part of the UML model,


provides a higher level of abstraction
(granularity).
A general-purpose element that comprises UML elements
- structural, behavioral or even grouping things.
Packages are conceptual groupings of the system and
need not necessarily be implemented as cohesive software
modules.
.

Accounts
Notation:
Department
Annotational Things (Note)

The explanatory part of the UML model; adds


information/meaning to the model elements.

A graphical notation for attaching constraints and/or


comments to elements of the model.

Parses user-query
Notation: and builds
expression stack
( invokes
ErrorHandler)
A Few Other Example
Relationships In UML

Dependency
Association
Generalization
Realization
Relationships (contd)

Dependency
Articulates the meaning of the links between
things.
A semantic relationship where a change in one thing (the
independent thing) causes a change in the semantics of
the other thing (the dependent thing).
Notation:
(arrow-head points to the independent thing)
Relationships (contd)

Association

A structural relationship that describes the


connection between two things.

Notation:
Associational (usage) relationships
1. multiplicity (how many are used)
* ⇒ 0, 1, or more
1 ⇒ 1 exactly
 2..4 ⇒ between 2 and 4, inclusive
 5..* ⇒ 5 or more
2. name (what relationship the objects have)
3. navigability (direction)
An Example

6..* enroll 0..*


Student Course
Course
0..*
0..* 1..*
advisee
teach

1
1
Faculty1
advisor
Association Class

Adds attributes and operations to an association


– Allows exactly one instance of the association class
between any two objects
– Can use an actual class instead, if you need more
0..* 1..*
Company Person
employer employee

Job
description
dateHired
salary
Special cases of Association

 Aggregation : "is part of" symbolized by a clear


white diamond.

 Composition : "is entirely made of“ symbolized by a


black diamond.
Aggregation

 Special form of association representing has-a or


part-whole relationship.
 Distinguishes the whole (aggregate class) from its
parts (component class).
 No relationship in the lifetime of the aggregate and
the components (can exist separately).

Aggregate Component
Aggregation Example

room

wall
Composition

Stronger form of aggregation


Implies exclusive ownership of the component class
by the aggregate class
The lifetime of the components is entirely included in
the lifetime of the aggregate (a component can not
exist without its aggregate).

Composition Component
A Composition Example

Document

0..*

Paragraph

1..*
Sentence

1..*
Word
An Example

University

1..*
1 1..* 1 0..*
College Department Student

1 1
chair-of member-of

1 1..*
Faculty
Relationships (contd)

Generalisation
A relationship between a general thing (called “parent”
or “superclass”) and a more specific kind of that thing
(called the “child” or “subclass”), such that the latter
can substitute the former.

Notation:
(arrow-head points to the superclass)
Generalization (inheritance) relationships
hierarchies drawn top-down with arrows
pointing upward to parent
line/arrow styles differ, based on whether
parent is a(n):
class:
solid line, black arrow
abstract class:
solid line, white arrow
An Example
Relationships (contd)

Realization
A semantic relationship between two things wherein one
specifies the behavior to be carried out, and the other
carries out the behavior.

Notation:
(arrow-head points to the thing being
realized)
Realization (representations)
Another example
Diagrams with UML

UML includes nine diagrams - each capturing a


different dimension of a software-system
architecture.

Class Diagram Statechart Diagram


Object Diagram Activity Diagram
Use Case Diagram Component Diagram
Sequence Diagram Deployment Diagram
Collaboration Diagram
Common Mechanism

Mechanisms/elements that apply consistently


throughout the language:
– Specifications
– Adornments
– Common Divisions
– Extensibility Mechanisms
Adornments

visibility:
+ public
# protected
- private
/ derived

underline static methods/attributes

parameter types listed as (name: type)

Italics Abstract Class


Common Division

There is a division of class and objects

Customer Joe : Customer

name
address : Customer
phone

Joe
Common Division

There is a separation of Interface and Implementation

Spellingwizard.dll

IUnknown

ISpelling
Extensibility Mechanism

Stereotype : Extends the vocabulary of the UML


Tagged value : Extends the properties of the UML
Constraints : Extends the semantics of the UML

EventQueue
{version=3.4
author =sia}
<<exception>>
Overflow
add() {ordered}
remove
flush()
Another Example (Stereotype)
Another Example (Tagged value)
Another Example (Constraints)
Revisiting Classes (Modeling advanced features)

Abstract, root and leaf elements


Multiplicity
Attributes Can be one of
changeable, addOnly, frozen
The Syntax of an attribute in the UML is

[visibility] name [multiplicity] [:type] [=initial-value] [{property-


string}]

Example-
+ name [0..1] :String
origin : Point = (0,0)
id : integer {frozen}
Operations
visibility name ( parameter-list ) : return-type { property-string }
Parameters can be marked as
can be:
in, out, inout
isQuery (does not change state of the object)
sequential (should not be called concurrently)
guarded (like synchronized)
concurrent (canbe executed concurrently)
Modeling static types (role-change)
Revisiting Association (Modeling advanced features)

Navigation
Unless otherwise specified, navigation across an
association is bidirectional.
Navigation could be limited to one direction. By
specifying the direction of traversal.
Visibility
Qualification
Interface Specifier
Class Diagrams

Multiplicity

Customer Simple
1
Class Aggregation

Abstract Rental Invoice


Class

Rental Item 1..*


1 0..1
Composition Simple
Generalization
Association

Checkout Screen
DVD Movie VHS Movie Video Game
Modeling a schema
Object Diagram
Interaction Diagram

Model the dynamic behaviour of the system; the flow


of control within an operation.
Describe the interaction between objects; objects
interact through messages to fulfill tasks.
Interaction provides behaviour and typically
implements a Use Case.
Two types of interaction diagrams in UML
– Sequence Diagrams (temporal dimension)
– Collaboration Diagrams (structural dimension)
Sequence Diagram
 Sequence diagram is an interaction diagram that
emphasizes the time-ordering of messages in an
interaction.
 Models interaction as a two-dimensional chart.
 Objects participating in the interaction are plotted
along the X-axis, time on the Y-axis.
 Y-axis models the objects lifeline.
 Messages passed between objects manifest the
interaction.
An Example
Collaboration diagram

 Collaboration diagram is an interaction diagram that


emphasizes the structural organization of objects
participating in an interaction.
It shows
– objects / classes
– links between them
– message flow along links
 Messages are numbered to show sequence
An Example
Use Case Diagram

Use Case Diagrams is the UML mechanism for


requirements capture.
Use Case Diagrams are a graphical presentation of
the “actors” in the domain and the “use cases”
initiated by them.
“Use cases” are abstractions of discrete behavior
exhibited by the system; perform a specific goal for
an “actor”.
An “actor” is an abstraction of a role played by
anyone or anything interacting with the system.
Common Uses

To Model the context of the system


To Model the requirements of the system.
Modeling the context of the system
Modeling the requirements of the system
Another Example (A complete picture)
Use Cases and Scenarios

A Use Case actually describes a set of sequences


[of actions].
Each sequence represents one possible flow of
actions in using the system.
Each sequence is called a Scenario.
A Scenario is basically one instance of a use case.
– a Scenario is to a Use Case, what an Object is to a Class.
Use Case Realization

 The use case diagram is an external view of the


system
 A use case is realized in a collaboration
 A collaboration shows an internal implementation-
dependent solution of a use case in terms of:
– classes/objects
– their relationships
– their interaction
Realization (A Higher level of Abstraction)
Realization
A Collaboration
1: msg1
:ClassA :ClassB
Use Case A
2: msg2

:ClassC 3: msg3 :ClassD

Use Case A description <<implements>> <<implements>> <<implements>>


1. Step 1
Class A Class B Class C
2. Step 2
3. ...
Oper1() Oper2() Oper3()
... ... ...

Vous aimerez peut-être aussi