Lecture - Sequence Diagram
Lecture - Sequence Diagram
Concepts
(Spring 2024)
Sequence Diagrams
06/11/2024 2
Interaction Models
• This can be user interaction, which involves user inputs and outputs.
• Interaction between the system being developed and other systems
• Or interaction between the components of the system.
Sequence Diagrams
• A sequence diagram shows the sequence of messages exchanged
by the set of objects (and optionally an actor) performing a certain
task.
• The objects are arranged from left to right across the diagram – an
actor that initiates the interaction is often shown on the left.
• The top of the diagram is the starting point, and time progresses
downwards towards the bottom of the diagram.
06/11/2024 4
Actors
Objects
06/11/2024 5
Lifelines
A vertical dashed line, called a lifeline, is attached to each object
or actor.
06/11/2024 7
Activations
The lifeline becomes a box, called an activation box, during
the period of time that the object is performing computations.
06/11/2024 8
message
Messages
A message is represented as an arrow between activation boxes of
the sender and receiver. You give each message a label.
06/11/2024 9
message
message
Sequence
Vertical position signifies sequence – earlier
messages appear nearer the top.
06/11/2024 10
E-mail Interface
06/11/2024 14
: user
06/11/2024 16
Add Objects
The first interaction is with the icon bar, which we can treat as an
object
: icon bar
: user
06/11/2024 17
Add Message
The user talks to the icon bar
: icon bar
: user
06/11/2024 18
: user
click send mail
: user
click send mail create
Now the user can see the email page and use it.
06/11/2024 20
: user
click send mail create
fill in to box
fill in subject box
fill in contents box
06/11/2024 21
: user
click send mail create
fill in to box
fill in subject box
fill in contents box
send
06/11/2024 22
: user
click send mail create
fill in to box
fill in subject box
fill in contents box
send
look up email address
: user
click send mail create
fill in to box
fill in subject box
fill in contents box
send
look up email address
: user
click send mail create
fill in to box
fill in subject box
fill in contents box
send
look up email address
submit email
06/11/2024 25
: user
click send mail create
fill in to box
fill in subject box
fill in contents box
send
look up email address
submit email
close
06/11/2024 26
: user
send mail( ) create
fill in to box
fill in subject box
fill in contents box
send
look up email address
submit email
close
06/11/2024 27
: user
send mail( ) create( )
enterTo( )
enterSubject( )
enterContents( )
send( )
getEmailAddress( )
submitEmail( )
close( )
06/11/2024 28
email page
create()
icon bar enterTo() address book
enterSubject()
send mail() enterContents() getEmailAddress()
send()
close()
email server
submitEmail()
Exercise
Consider the following scenario and draw sequence diagram for
online book shop.
Sequence Fragment
Alternative Fragment
• The alternative fragment is used when a choice needs to be
made between two or more message sequences. It models
the “if then else” logic.
Option Fragment
• The option fragment is used to indicate a sequence that will
only occur under a certain condition, otherwise, the
sequence won’t occur. It models the “if-then” statement.
Exercise
Draw a sequence diagram that represents the process of exam conduction
described in the case study below:
Before the exam conduction, the instructor first informs the students of the exam
date and the syllabus (material) included as part of exam. The instructor then
prepares the exam paper. The instructor then gets the exam paper copied from
staff to produce enough copies for the students, and later the instructor hands
over the exam paper to the students on the designated time and location.
The students are required to write their answers against questions listed in the
exam paper. Students should hand in their solution sheet to the instructor before
time runs out.
The instructor then gives the solution sheet of students to the Teaching
Assistance (TAs), along with sample solutions to each question, and gets them to
mark it. TAs then return solution Sheet to instructor after marking. She then
records all marks and inform result to the students.
06/11/2024 36
• Loop Fragment
• Reference fragment
06/11/2024 37
Chapter Reading
• Chapter 5, System Modeling,
Software Engineering by Ian Sommerville