1 UML Sequence Diagram
1 UML Sequence Diagram
1
2
Objectives
To present the UML sequence diagram notation
To present heuristics for making good sequence diagrams
3
Sequence Diagrams
A Sequence diagram is a structured representation of behavior as
series of sequential steps over time.
sd MySequenceDiagram
8
Sequence Diagram Lifelines
A lifeline represents an individual participant in a sequence
diagram.
A lifeline will usually have a rectangle containing its object name.
The vertical dimension represents time; the dashed line shows
the period when an individual exists.
9
Sequence Diagram Lifelines
Sometimes a sequence diagram will have a lifeline with an actor
element symbol at its head. This will usually be the case if the
sequence diagram is owned by a use case.
Boundary, control and entity elements
Messages and Execution Occurrence
10
operator
a b c
compartment
operator m1
combined m2
fragment
m3
operand
region
m2
m4
14
Alternative Fragment
A combined fragment with one or more guarded
operands whose guards are mutually
exclusive.
At most one of the operands will be chosen. The
chosen operand must have an explicit or implicit
guard expression that evaluates to true at this
point in the interaction.
An implicit true guard is implied if the
operand has no guard.
An operand guarded by else means a guard
that is the negation of the disjunction of all
other guards. If none of the operands has a
guard that evaluates to true, none of the
operands are executed and the remainder of the
enclosing interaction fragment is executed.
15
Alternative Fragment
Example
sd toggle()
self:Light :Bulb
alt [state==on]
turnOff()
[state==off]
turnOn()
16
Opt Fragment
The interaction operator opt means that the combined fragment
represents a choice of behavior where either the (sole) operand
happens or nothing happens.
An option is semantically equivalent to an alternative combined
fragment where there is one operand with non-empty content and
the second operand is empty.
17
Opt Fragment Example
sd print( f : File )
isCmprsd=isCompressed()
opt [isCmprsd]
decompress()
print(f)
18
Loop Fragment