Professional Documents
Culture Documents
Swe-Sequence Diaram 2023
Swe-Sequence Diaram 2023
Swe-Sequence Diaram 2023
Introduction
• The dynamic interaction of objects is modeled in, uml, using the
interaction diagrams.
• Interaction diagrams are models that describe how group of objects
collaborate to realize some behavior.
• An interaction diagram shows the interactive behaviour of the system
and the messages that are passed between the objects within the
use case.
• There are two kinds of interaction diagrams: sequence diagrams and
collaboration diagrams. These two diagrams are equivalent in the
sense that any one diagram can be derived automatically from the
other. However, they are both useful.
– Communication Diagrams: Illustrate object interactions organized around the
objects and their links to each other
– Sequence Diagrams: Illustrate object interactions arranged in time sequence
• This lesson illustrates in more details sequence diagram.
Sequence Diagrams
• Sequence diagrams describe in detail how actors use use cases;
they can also model external business processes the new system
will support (e.g., processing a book order)
• An interaction is a behavior that consists of a set of messages
exchanged between external and system objects.
• Interactions consist of one or more messages. Interactions
may be synchronous (e.g., calling someone on the phone), or
asynchronous (e.g., sending someone email).
• Sequence diagrams defined during requirements analysis
should not:
• include design objects;
• specify message signatures in any detail;
Student Guide
X-Axis (objects)
member: :Book
book:Book
LibraryMember Copy
borrow(book) Object
Life Line
ok = mayBorrow()
Y-Axis (time)
message
Activation
[ok] borrow(member) box
setTaken(member)
condition
Sequence Diagrams 8
Sequence Diagram notation
AN ACTOR
Participates in a sequence by sending and/or
receiving messages
AN OBJECT anObject:aClass
Participates in a sequence by sending and/or receiving
messages
A LIFELINE
Denotes the life of an object during a sequence
A FOCUS OF CONTROL
Denotes when an object is sending or receiving
messages
A MESSAGE
Conveys information from one object to another A Message()
one
OBJECT DESTRUCTION
An X is placed at the end of an object’s lifeline to show x
that it is going out of existence
Sequence diagram notation: object
Actors
Objects
:Object 1 :Object 2
Lifelines
Identify the existence of the object over time.
Sequence diagram notation: activation
:Object 1
Activations
Indicate when an object is performing an action
Sequence diagram notation: Messages
:Object 1 :Object 2
message
Messages
Indicate the communications between objects
Messages
• Messages:
– are used to model the content of communication between objects.
– are used to convey information between objects and enable objects to request services of
other objects.
– is the invocation of an object's operation from another (possibly the same) object.
– is shown as a horizontal solid arrow from the lifeline of one object to the lifeline of
another object.
• The first message of a sequence diagram always starts at the top and is typically
located on the left side of the diagram for readability.
• Subsequent messages are then added to the diagram slightly lower then the previous
message.
• The message instance has a sender, receiver, and possibly other information
according to the characteristics of the request.
• The sender will send the message and receiver will receive the message.
• In case of a message from an object to itself, the arrow may start and finish on the
same object symbol.
• A message is labeled at minimum with the message name. Arguments and control
information (conditions, iteration) may be included.
Sequence dg. from use case
15
Messages types
• The message arrows represent the communications between two objects
in a sequence diagram. It goes from the lifeline of one object to that of
another object
• According to the arrows symbols the messages classified to:
– Synchronous message- the caller has to wait for the receiving
object to complete execution of the called operation before it can
resume execution.
• Symbol:
– Asynchronous message – The caller can execute immediately after
sending the message, it does not has to wait for the recipient to
handle the message
• Symbol:
• OR
– A return of control from the synchronous message
• Symbol
Async Message Example
Synchronous message
Coming up: Components: Guards Asynchronous message
Return message
Synchronous Messages
:A :B
doYouUnderstand()
return
Caller
yes (optional)
Blocked
Messages types
Synchronous & Asynchronous Messages
getValue unknown
price ring
setID log
Example Example
When modeling a sequence diagram, there will be times that an object will need to send a
message to itself.
This is drawn as an arrow looping back on itself as shown.
A self message can represent a recursive call of an operation, or one method calling another
method belonging to the same object.
It is shown as creating a nested focus of control in the lifeline’s execution occurrence.
A typical example of this is close. You can place a button on a form and when you click it, it
Object Creation
• An object may create another object via a
<<create>> or new message.
– Object life starts at that point
Create
B
X
Return
Deletion
24
Lifeline
Object Destruction
:A :B
<<destroy>>
25
Message Specification
• Every synchronous and asynchronous arrow must be labeled
with a message specification on top of the message arrow.
• The message format :
*insertChange(coin) lookupCoin(coin)
price
Iteration
displayPrice(owedAmount)
[owedAmount<0] returnChange(-owedAmount)
Condition
Use Cases for a
Meeting Scheduling System
Sequence Diagram
Object
pressButton1() blinkHours()
pressButton1() blinkMinutes()
pressButton2() incrementMinutes()
refresh()
pressButtons1And2()
commitNewTime()
stopBlinking()
Message
Activation
36
Application
Example:
Normal Flow of Events:
Slide 38
Sequence diagrams - example
call
ack
number
call
ack
transfer
talk
time
Summary
Ans: d
• The focus in a sequence diagram is on __________________
a. How actors interact with objects to realize a given use case
b. Messages sent by actors to other objects
c. when an object is being created
d. when messages are being destroyed
e. time ordering of messages being passed between objects
• Ans: e
• The order of messages on a sequence diagram goes from ____ to
_____.
a. right to left
b. bottom to top
c. left to right
d. top to bottom
e. left to right, top to bottom
• Ans: d