You are on page 1of 20

Sequence Diagram

Object Oriented Design


• Design consists of the following steps :
– Refine the class diagram.
– Draw the interaction diagrams for the system.
–Sequence Diagram
–Collaboration Diagram
• Sequence diagrams models the collaboration
of objects based on a time sequence. It shows
how the objects interact with others in a
particular scenario of a use case.
Sequence Diagram
• Shows how objects communicate with each other
over time.
– That is, sequence diagrams are used to model object
interactions arranged in time sequence and to distribute
use case behavior to classes.
– They can also be used to illustrate all the paths a particular
use case can ultimately produce.

• The sequence diagram consists of Active Objects,


Messages represented as solid-line arrows, and Time
represented as a vertical progression.

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

Link OBJ files


Write EXE file

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

• Model a single instance through a scenario


• Use separate diagrams or parts of diagrams to
model alternate scenarios

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

You might also like