0% found this document useful (0 votes)
10 views23 pages

1 UML Sequence Diagram

Uploaded by

wdxyfxdxpz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views23 pages

1 UML Sequence Diagram

Uploaded by

wdxyfxdxpz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 23

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.

 Sequence diagrams are good at showing:


 Which objects communicate with which other objects; and
 What messages trigger those communications.

 Sequence diagrams are not intended for showing complex


procedural logic.
4
Fun Example Objects
5
Fun Example Sequence Diagram
6
Fun Example Sequence Diagram
7
Sequence Diagram Frames
Frame—a rectangle with a pentagon in the upper left-hand corner
called the name compartment.
 sd interactionIdentifier
 interactionIdentifier is either a simple name or an operation
specification as in a class diagram

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

 Messages are displayed as arrows.


 The first message is a synchronous
message (denoted by the solid
arrowhead) complete with an implicit
return message.
 The second message is asynchronous
(denoted by line arrowhead),
 The third is the asynchronous return
message (denoted by the dashed line).
 The source object sends two messages
and receives two replies;
11
Self-Message
 A Self-Message reflects a new process
or method invoked within the calling
lifeline's operation.

Hint: Use a self message when you are


calling functions in the class which either
don't call other functions, don't send any
messages (or they do but you don't want
to show this in the sequence).
12
Lifeline Start and End
A lifeline may be:
 Created: the symbol at the
head of the lifeline is shown at
a lower level down the page
than the symbol of the
object that caused the
creation.
 or
 Destroyed (the lifeline is
terminated by a stop symbol,
Tip (EA tool): create a regular represented as a cross) during
message the timescale represented by a
then change the “Lifecycle”
sequence diagram.
property to “new or delete”.
13
Combined Fragments
 One or more processing sequence enclosed in a frame and
executed under specific named circumstances.
sd Example

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 )

self:PrintServer f:File :Printer

isCmprsd=isCompressed()

opt [isCmprsd]

decompress()

print(f)
18
Loop Fragment

 The interaction operator loop means that


the combined fragment represents a loop.

 The loop operand will be repeated a


number of times.
19
Loop Fragment Example
20
Break Fragment
sd print( f : File )
 When a break combined
fragment's message is to be
self:PrintServer stderr f:File :Printer
executed, the enclosing
readable=canRead()
interaction's remainder
break
messages will not be executed
[!readable]
print(errMsg)
because the sequence breaks
out of the enclosing interaction.
isCmprsd=isCompressed()

 Breaks are most commonly


opt [isCmprsd]
used to model exception
decompress()
handling.
print(f)
21
Parallel Fragment

 Defines potentially parallel execution of


behaviors of the operands of the combined
fragment.
 Different operands can be interleaved in any
way as long as the ordering imposed by each
operand is preserved.
 Tip (EA tool): Use condition “anonymous” to
create a swimlane without a condition.
22
Nested Diagram
 An interaction occurrence is a reference to another diagram
which has the word "ref" in the top left corner of the frame, and
has the name of the referenced diagram shown in the middle of
the frame.
23
Sequence Diagram Heuristics
 Put the sender of the first message leftmost.
 Put pairs of individuals that interact heavily next to one another.
 Position individuals to make message arrows as short as possible.
 Position individuals to make message arrows go from left to right.
 Put the self lifeline leftmost.
 In a sequence diagram modeling an operation interaction, draw
the self execution occurrence from the top to the bottom of the
diagram.
 Suppress messages individuals send to themselves unless they
generate messages to other individuals.
 Suppress return arrows when using execution occurrences.

You might also like