CSC291 – Software Engineering
Concepts
Lecture 24
Sequence Diagrams
5/18/2023 CSC291 - Software Engineering Concepts 2
Beginnings of a Method
Systems
Model
5/18/2023 CSC291 - Software Engineering Concepts 3
Interaction Models
All systems involve interaction of some kind…
• 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
Use case modeling, which is mostly used to model interactions
between a system and external actors (users or other systems).
Sequence diagrams, which are used to model interactions between
system components, although external agents may also be included.
5/18/2023 CSC291 - Software Engineering Concepts 4
UML Sequence Diagrams
• Describe the flow of messages, events, actions between
objects
• Show time sequences that are not easily depicted in other
diagrams
• Typically used to understand the logical flow of system
• Emphasis on time ordering!
5/18/2023 CSC291 - Software Engineering Concepts 5
Sequence Diagram Key Parts
• In a sequence diagram, objects and actors are aligned along
the top of the diagram.
• Labeled arrows indicate operations; the sequence of
operations is from top to bottom.
• The axes in a sequence diagram:
– horizontal: which object/participant is acting
– vertical: time
5/18/2023 CSC291 - Software Engineering Concepts 6
Developing Sequence Diagrams
• Identify the relevant objects involved in the computation
• Establish the role of each object
• Identify the controller
• Decide messages between objects
5/18/2023 CSC291 - Software Engineering Concepts 7
Sequence Diagram Notation
Object1 name:classname Object 2name:classname
Actors Objects
5/18/2023 CSC291 - Software Engineering Concepts 8
Sequence Diagram Notation
:Object 1 :Object 2
Lifelines
Identify the existence of the object over time.
5/18/2023 CSC291 - Software Engineering Concepts 9
Sequence Diagram Notation
:Object 1 :Object 2
Activations
Indicate when an object is performing an action
5/18/2023 CSC291 - Software Engineering Concepts 10
Sequence Diagram Notation
:Object 1 :Object 2
message
Messages
Indicate the communications between objects
5/18/2023 CSC291 - Software Engineering Concepts 11
Sequence Diagram Notation
:Object 1 :Object 2
message
message
Sequence
Vertical position signifies sequence – earlier
messages appear nearer the top.
5/18/2023 CSC291 - Software Engineering Concepts 12
Sequence Diagram
• Tracks a sequence of events in a scenario
• Identifies all objects involved
Objects
O1 O2 O3 O4 O5 indicates
that the
E1 event
E2 effects the
Events object
E3
E4
5/18/2023 CSC291 - Software Engineering Concepts 13
Sequence Diagram (make a phone call)
5/18/2023 CSC291 - Software Engineering Concepts 14
A Simpler Example - Sending an email
5/18/2023 CSC291 - Software Engineering Concepts 15
E-mail Interface
5/18/2023 CSC291 - Software Engineering Concepts 16
Working From a Scenario
Sending an email
1. Press “New ” email icon
2. Enter person’s name in “To” section
3. Type subject
4. Type contents
5. Press Send button
6. System looks up email address in address book
7. System submits the email to the email server
5/18/2023 CSC291 - Software Engineering Concepts 17
Starting The Diagram
• If this is an interactive scenario, we always have an actor
driving it
: user
5/18/2023 CSC291 - Software Engineering Concepts 18
Add Objects
The first interaction is with the icon bar, which we can treat as an
object
: icon bar
: user
5/18/2023 CSC291 - Software Engineering Concepts 19
Add Message
The user talks to the icon bar
: icon bar
: user
5/18/2023 CSC291 - Software Engineering Concepts 20
Label The Communication
: icon bar
: user
click send mail
Remember that actors can only communicate with interface
objects such as screens, menus and icon bars.
5/18/2023 CSC291 - Software Engineering Concepts 21
The icon bar has some work to do.
It creates an email page.
: icon bar : email page
: user
click send mail create
Now the user can see the email page and use it.
5/18/2023 CSC291 - Software Engineering Concepts 22
The next three steps are filling in the details on
the email page
: icon bar : email page
: user
click send mail create
fill in to box
fill in subject box
fill in contents box
5/18/2023 CSC291 - Software Engineering Concepts 23
The User then clicks Send
: icon bar : email page
: user
click send mail create
fill in to box
fill in subject box
fill in contents box
send
5/18/2023 CSC291 - Software Engineering Concepts 24
Now consider how to do the sending
: icon bar : email page : address book
: user
click send mail create
fill in to box
fill in subject box
fill in contents box
send
look up email address
We can choose to get the email page to look up the email
address from an address book object
5/18/2023 CSC291 - Software Engineering Concepts 25
The arrow allows information to return
: icon bar : email page : address book
: user
click send mail create
fill in to box
fill in subject box
fill in contents box
send
look up email address
So we don’t need to put a return arrow with the email
address going back to the email page
5/18/2023 CSC291 - Software Engineering Concepts 26
We can choose to get the email page to submit the email
to the email server
: icon bar : email page : address book : email server
: user
click send mail create
fill in to box
fill in subject box
fill in contents box
send
look up email address
submit email
5/18/2023 CSC291 - Software Engineering Concepts 27
And if we think carefully, the email page always closes after
the send.
: icon bar : email page : address book : email server
: 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
5/18/2023 CSC291 - Software Engineering Concepts 28
Now we go through and change the messages to
operations on the object
: icon bar : email page : address book : email server
: user
send mail( ) create
fill in to box
fill in subject box
fill in contents box
send
look up email address
submit email
close
5/18/2023 CSC291 - Software Engineering Concepts 29
And so on, all the way through
: icon bar : email page : address book : email server
: user
send mail( ) create( )
enterTo( )
enterSubject( )
enterContents( )
send( )
getEmailAddress( )
submitEmail( )
close( )
5/18/2023 CSC291 - Software Engineering Concepts 30
And now we have found our objects, and the operations on
them
email page
create()
icon bar enterTo() address book
enterSubject()
send mail() enterContents() getEmailAddress()
send()
close()
email server
submitEmail()
So we drag them onto a class diagram
5/18/2023 CSC291 - Software Engineering Concepts 31
Exercise
Consider the following scenario and draw sequence diagram for
online book shop.
“Online customer can search book catalog, view description of
a selected book, add book to shopping cart, do checkout”.
5/18/2023 CSC291 - Software Engineering Concepts 32
Solution
5/18/2023 CSC291 - Software Engineering Concepts 33
Chapter Reading
• Chapter 5, System Modeling,
Software Engineering by Ian Sommerville
Course Material Link:
https://sites.google.com/cuilahore.edu.pk/sec