Professional Documents
Culture Documents
3
Sequence Diagram Elements
• Time • Messages
• Objects – Messages to other
objects
• Object Lifelines
– Messages to self
– Object creation
– Object destruction
• Synchronization
• Returns
• Conditionals
• Iteration
4
Sequence Diagram - Objects
• A life line illustrates what is happening to an
object in a sequential fashion.
:Name Object
Life line
Activation
5
Sequence Diagram – Time & Messages
• Messages are used to illustrate communication between
different active objects of a sequence diagram.
:Name1 :Name2
Actor
Message One
Message Two
6
Types of Action
• synchronous call
• asynchronous call
• Create
• delete
• reply
7
Synchronous Call
• It typically represents operation call - send
message and suspend execution while waiting
for response.
• Synchronous call messages are shown with
filled arrow head.
Asynchronous Call
• It send message and proceed immediately
without waiting for return value.
Asynchronous messages have an open arrow
head.
Create Message
• Create message is sent to a lifeline to create
itself. It is shown as a dashed line with open
arrowhead (looks the same as reply message),
and pointing to the created lifeline's head
Delete Message
• Delete message is sent to terminate another
lifeline. The lifeline usually ends with a cross in
the form of an X at the bottom denoting
destruction occurrence.
Creation and destruction of object
Targets that exist at the start of an interaction are placed at the top of the diagram.
Any targets that are created
during the interaction are placed further down the diagram, at their time of creation.
Reply Message
• Reply message to an operation call is shown
as a dashed line with open arrow head (looks
similar to creation message).
Sequence Diagram – Compilation
:Compiler Linker FileSystem
Actor
Compile Load Files
Load Files
Compile files
c
Save OBJ Files c Save OBJ Files
Link
Load OBJ files
14
Sequence Diagram Basics
• Time moves down
– Time is relative
– Exact timings require a Timing Diagram
• Lifeline shows when object is active on stack
– Dashed line when inactive
– Double line when active
15
Sequence Diagram Options
• Return arrows are optional
– Data on return arrows is optional
• Stack activation lines for recursion or self-calls
• Arrow format is important
– Synchronous flow: solid line, filled arrowhead
– Asynchronous flow: solid line, stick or half arrowhead (UML
1.3)
– Return: dashed line, stick arrowhead
• Messages can have guards
• Variable names
• Parameter values
16
Using Sequence Diagrams
17
When to use Sequence Diagrams
• Model the behavior of collaborating objects
over time
• Model behavior of several objects in a single
use case
• Visualizing collaborations between several
objects
18
Withdraw Money Sequence Diagram