Object
Interaction
Sequence Diagrams
Week 7
1
Objectives:
To model object collaboration using an interaction
sequence diagrams
Identify and transform the use case specification
into sequence diagrams using UML notation.
2
Interaction Diagram
Interaction diagram is used to describe the
object interaction.
It is used to determine the most appropriate
scheme of messaging between objects in order
to support a particular user requirements.
2 types of interaction diagram:
- sequence diagram
- collaboration diagram
3
Sequence Diagrams
The sequence diagram shows the interactions
among objects that participate in a use case and
the message that pass between them over time
for one use case.
It is a dynamic model that shown in a time
sequence.
Typically used to represent the detailed
interaction among object of the classes, not
among the classes themselves.
4
Sequence Diagrams….
Each use case has a number of flows
(basic flow, exceptional flows and
alternative flows)
Each sequence diagram represents of the
flows through use case diagram.
5
Elements of Sequence Diagrams
Actor
- A person/system that participates in a
sequence by sending or receiving
message.
- place across the top of the diagram using
actor symbol (refer use-case diagram)
Actor
6
Elements of Sequence Diagrams…
Object
- Place across the top of the diagram
using object symbol. Participates in a
sequence by sending or receiving
message.
Object
7
Elements of Sequence Diagrams…
Message
- Objects communicate by sending
messages
- Message is an information sent to objects
to execute one of its behaviour.
- using solid lines connecting two objects.
CustomerPanel DrinkMgr
Select drink
8
Elements of Sequence Diagrams…
lifeline
- using dotted line runs vertically below each actor
and object to denote the life line of the actor/object
over time.
I
I
I
I
I
9
Elements of Sequence Diagrams…
Focus of control
- is a long, narrow rectangle placed a top a
lifeline.
- indicates times during an activation when
processing is taking place within the object.
10
Elements of Sequence Diagrams
Reflexive message
- object can send message to itself
Object
message
11
Example of Sequence diagram
Scenario : Joe, a bank customer withdrawing $20
from the ATM
The process begins when Joe inserts his card into the
card reader. The card reader reads the number on Joe’s
card, then tells the ATM screen to initialize itself. The
ATM prompts Joe for his PIN. Joe enters his PIN and
the ATM opens his account. Joe’s PIN is validated, and
the ATM prompts him for a transaction. Joe selects
Withdraw. The ATM prompts Joe for the withdrawal
amount. Joe enters $20. The ATM verifies that Joe’s
account has sufficient funds, and subtracts $20 from
the account. The ATM dispenses $20 and ejects Joe’s
card.
12
Example of Sequence diagram…
Joe : Customer Card Reader ATM Screen Cash dispenser ATM Manager Joe Account
insert card
read card no.
send card no.
object
Reflexive
message
initialize screen
prompt PIN
enter PIN
send PIN retrieve PIN Lifeline
vali date PIN
Focus
of control
Complete Sequence diagram 13
Steps for building Sequence
Diagram
Set the context of sequence diagram
- define which use case/ a scenario of a use
case (normal flow, alternative flow and
exceptional flow)
Identify which actor will involve
Identify which objects will participate
Set the lifeline for each object
Layout the message from the top to the bottom
of the diagram based on the order in which they
are are sent.
14
Steps for building Sequence
Diagram….
Add the focus of control to each object’s
life
Validate the sequence diagram
15
Exercise
It’s time
to do the
exercise
16
Based on the use case specification given,
draw a sequence diagram for basic flow of
Buy Drink
Use Case Specification
17
ANSWER
Sequence Diagram for basic flow of Buy Drink
18