0% found this document useful (0 votes)
75 views

Lecture 08 Sequence Diagram

The document provides an overview of sequence diagrams in UML modeling. It defines key parts of a sequence diagram including participants, messages, and axes. It explains how to represent objects, messages between objects, different message types, method execution, and lifetime of objects. Examples are provided to illustrate a sequence diagram modeling a use case scenario.

Uploaded by

Mateen Habib
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
75 views

Lecture 08 Sequence Diagram

The document provides an overview of sequence diagrams in UML modeling. It defines key parts of a sequence diagram including participants, messages, and axes. It explains how to represent objects, messages between objects, different message types, method execution, and lifetime of objects. Examples are provided to illustrate a sequence diagram modeling a use case scenario.

Uploaded by

Mateen Habib
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 24

Object-Oriented Software

Engineering
Lecture # 07

MODELING WITH UML

2
Outline

• Overview of sequence Diagram

• Syntax and Semantics

• Examples

Mehak Fatima 3
intro
an overview of sequence diagrams

Mehak Fatima
4
What is a U M L sequence diagram?

• Sequence diagram: an “interaction diagram” that models a


single scenario executing in a system
• 2nd most used UML diagram (behind class diagram)
• Shows what messages are sent and when

• Relating UML diagrams to other design artifacts:


• CRC cards → class diagrams
• Use cases → sequence diagrams

Mehak Fatima
5
Key parts of a sequence
diagram

• Participant: an object or an
:Client :Server
entity; the sequence diagram
actor checkEmai
• sequence diagram starts with an l sendUnsentEma
il
unattached "found message"
arrow newEmail
response
[newEmail]
get

deleteOldEmail

Mehak Fatima
6
Key parts of a sequence
diagram

• Participant: an object or an
:Client :Server
entity; the sequence diagram
actor checkEmai
• sequence diagram starts with an l sendUnsentEma
il
unattached "found message"
arrow newEmail
respons
• Message: communication between e
[newEmail] get
objects
deleteOldEmail

Mehak Fatima
7
Key parts of a sequence
diagram

• Participant: an object or an
:Client :Server
entity; the sequence diagram
actor checkEmai
• sequence diagram starts with an l sendUnsentEma
il
unattached "found message"
• Message: communication between
arrow newEmail
objects
respons
• Axes in a sequence diagram: e
[newEmail] get
• horizontal: which participant is
acting deleteOldEmail

• vertical: time (↓ forward in time)

Mehak Fatima
8
Key parts of a sequence
diagram

• Participant: an object or an
:Client :Server
entity; the sequence diagram
actor checkEmai
• sequence diagram starts with an l sendUnsentEma
il
unattached "found message"
• Message: communication between
arrow newEmail
objects
respons
• Axes in a sequence diagram: e
[newEmail] get
• horizontal: which participant is
acting deleteOldEmail

• vertical: time (↓ forward in time)

Mehak Fatima
9
Sequence diagram from a use
case

1. The user presses the “check email”


:Client :Server
button.
2. The client first sends all unsent email checkEmai
l sendUnsentEmail
to the server.
3. After receiving an acknowledgement, newEmail
the client asks the server if there is response
any new email. [newEmail]
getEmail
4. If so, it downloads the new email.
deleteOldEmail
5. Next, it deletes old thrashed
email from the server.

Mehak Fatima
10
basics
sequence diagrams: syntax and semantics

Mehak Fatima
11
Representing objects

objectname:classna
me
• An object: a box with an Named Anonymous
underlined label that specifies the object object
object type, and optionally the
object name. Smith:Patient :Patient Smith
• Write the object's name if it clarifies
the diagram. Object of unknown
class

Mehak Fatima
12
Representing objects

objectname:classna
me
• An object: a box with an Named Anonymous
underlined label that specifies the object object
object type, and optionally the
object name. Smith:Patient :Patient Smith
• Write the object's name if it clarifies
the diagram. Object of unknown
• An object's "life line" is represented class
by a dashed vertical line. Lifelin
• Represents the life span of the object e
during the scenario being modeled.

Mehak Fatima
13
Representing messages between
objects

• A message (method call): :Hospital


horizontal arrow to the receiving
object.
admit(patientID,
• Write message name and arguments roomType)
above the arrow.

Mehak Fatima
14
Different types of messages

:Controller
• Type of arrow indicates types of
messages:
• Synchronous message: solid arrow with a solid
head.
• Asynchronous message: solid arrow with a stick
head.
• Return message: dashed arrow with stick head.

Mehak Fatima
15
Indicating method execution

:Controller
• Activation: thick box over object's life line,
drawn when an object's method is on the stack
• Either that object is running its code,
or it is on the stack waiting for another object's
method to finish
• Nest activations to indicate an object calling
itself. :Controller

Mehak Fatima
16
Lifetime of objects

• Object creation: an arrow with new :Handler


written above it
queryD
• An object created after the start of the B new
scenario appears lower than the others. :Query

• Object deletion: X at the bottom execute


of object's lifeline results
.

Mehak Fatima
17
Alternatives, options, and loops

• Frame: a box around part of a sequence diagram


• if → (opt) [condition]
• if/else → (alt) [condition], separated by horizontal
dashed line
• loop → (loop) [condition or items to loop over]

:Order careful:Distributor regular:Distributor


dispatc
h
loop [for each line item]

alt [value>1000 dispatc


] h

[else dispatc
] h

Mehak Fatima
18
Linking sequence diagrams

• If one sequence diagram is too large or refers to another


diagram:
• An unfinished arrow and comment.
• A ref frame that names the other diagram.

The flow is
customerInf
re
pars continued in
o e
f Diagram 2.
Verify Customer Credit
approve
d

Mehak Fatima
19
W h y use sequence diagrams? W h y not code
it?

• A good sequence diagram is still above the level of the


real code (not all code is drawn on diagram)
• Sequence diagrams are language-agnostic (can be
implemented in many different languages)
• Non-coders can read and write sequence
diagrams.
• Can see many objects/classes at a time on same
page

Mehak Fatima
20
study
sequence diagrams: example

Mehak Fatima
21
Online bookstore example

1. The customer begins the interaction by searching for a book by title.


2. The system will return all books with that title.
3. The customer can look at the book description.
4. The customer can place a book in the shopping cart.
5. The customer can repeat the interaction as many times as desired.
6. The customer can purchase the items in the cart by checking out.

Mehak Fatima
22
Online bookstore sequence diagram

Mehak Fatima
23
Summary

• A sequence diagram models a single


scenario executing in the system.
• Key components include participants
and messages.
• Sequence diagrams provide a high-
level view of control flow
patterns through the system.

Mehak Fatima
24

You might also like