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

DFP40182 Sequence Diagram

Sequence diagrams model interactions between objects in a use case. They illustrate how system parts interact and the order of interactions. A sequence diagram contains lifeline notations representing objects, activation bars indicating object activity, and message arrows showing interactions between objects.

Uploaded by

flamezodiark
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

DFP40182 Sequence Diagram

Sequence diagrams model interactions between objects in a use case. They illustrate how system parts interact and the order of interactions. A sequence diagram contains lifeline notations representing objects, activation bars indicating object activity, and message arrows showing interactions between objects.

Uploaded by

flamezodiark
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

Sequence

Diagram
What is a SequenceDiagram?
 Sequence diagrams, commonly used by developers,
model the interactions between objects in a single use
case.

 They illustrate how the different parts of a system


interact with each other to carry out a function, and
the order in which the interactions occur when a
particular use case is executed.
Sequence DiagramNotations
Element of SequenceDiagram
 A sequence diagram is structured in such a way that it
represents a timeline which begins at the top and descends
gradually to mark the sequence ofinteractions.

 Eachobject has a column and the messages exchanged


between them are represented with arrows.

• Lifeline Notation
• Activation Bars
• Message Arrows
• Comment
i) Lifeline Notation
 A sequence diagram is made up of several
of these lifeline notations

 They should be arranged horizontally across


the top of the diagram

 No two lifeline notations should overlap each


other

 They represent the different objects that


interact with each other in the system

 A lifeline notation with an actor element


symbol isused when the sequence diagram is
owned by a use case
ii) Activation Bars
 Activation bar is the box placed onthe
lifeline

 It indicates thatan object is active


((or instantiated) during an
interaction between two objects

 The length of the rectangle indicates


the duration of theinteraction
iii) MessageArrows

 An arrow from the Message Caller to the MessageReceiver


specifies a message

 The message can flow in any direction; from left to right, right to
left and back to the calleritself

 The description of the message should go on the arrow

 Arrow heads may change according to different messagetypes


Different Message Types

i. Synchronous message
ii. Asynchronous message
iii. Return message
iv. Participant creation message
v. Participant destruction message
vi. Reflexive message
 A synchronous message is used when the sender waits for the receiver to
process the message and return before carrying on with another message

 An asynchronous message is used when the message caller does not


wait for the receiver to process the message and return before
sending other messages to other objects within thesystem
Example (sync and async message)
 A return message is used to indicate that the message receiver is
done processing the message and is returning control over to the
message caller.

 When an object sends a message to itself, it is called a reflexive


/self message. It is indicated with a message arrow thatstarts and
ends at the samelifeline
Example (return and reflexive/self message)
• Participant creation message; objects can be created in the middle
of a sequence. The dropped participant box notation is used when
you need to show that the particular participant did not exist until
the create call was sent.

• Participant destruction message; participants, when no longer


needed, can also be deleted from a sequence diagram. This is done
by adding an ‘X’ at the end of the lifeline of the said participant.
How to Draw a SequenceDiagram
 A sequence diagram represents the scenario or flow of events in
one single use case. The message flow of the sequence diagram is
based on the narrative of the particularuse case.

 Before you start drawing the sequence diagram ordecide what


interactions should be included in it, you need to ready a
comprehensive description of the particular use case.
Step 1 : Identify the objects or participants

Step 2 : List down the steps involved in the


execution of the use case

Step 3 : Identify which messages should be


passed between the objects we identified
earlier as the system executes these steps.
Then draw the sequence diagram
Practical Exercise 1:
Model a scenario of the Withdraw Money use case of a Bank
ATM system. The user is able to make withdrawal of money.
The system employs a standard procedure of validating the
card and account holder’s password.
a) Describe the main objects (2 in this case):
• Cardholder (or Customer)
• ATM System
b) Describe the main flow of events in this scenario. The first
2 events are listed below:
• Customer arrives at the ATM machine and inserts a bank
card.
• The system requests for user authentication (password).
Solution :
• Main Objects:
1. Customer
2. ATM System
• Ideal Main Flow of Events:
1. Customer arrives at the ATM machine and inserts a bank card - sync
2. The system requests for user authentication (request PIN number) -return
3. Customer inserts PIN number - sync
4. System prompts user to select services -return
5. Customer request withdrawal of money - sync
6. System prompts the amount of withdrawal -return
7. Customer enters withdrawal amount - sync
8. System displays success of request message -return
9. System ejects card -return
10. System dispense money -return
Answer (Sequence Diagram)
Practical Exercise 2:

FE Jun 2018
(9 Marks)
Sequence Diagram Best Practices
 Manage complex interactions with sequence fragments

• Sequence fragments are used to show complex interactions such as


alternative flows and loops in a more structuredway.

• A sequence diagram is drawn as a box that frames a section of


interactions between objects in a sequencediagrams.

• On the top left corner of thefragment sits an operator. This – the


fragment operator - specifies what sort of a fragment it is.
Alternative CombinationFragment
• It is used when a choice needs to be made between two or
more
message sequences. It models the “if then else” logic

• It is specified by mentioning ‘alt’inside the frame’s name box

• To show 2 or more alternatives, the frame is divided into what


is called interaction operands using a dashed line

• Each operand has a guard to test against and it is placed at the


top
left corner of the operand
Example (Alternative Combination
Fragment)
Option Combination 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

• It is represented with a rectangular frame where ‘opt’ is


placed inside the name box

• Unlike the alternative fragment, the option fragment is not


divided to operands
Example (Option Combination Fragment)
Loop Fragment
• It is used to show a repetitive sequence

• It is drawn as a frame and specified by placing ‘loop’


in the name box

• It can be used
– for the Boolean test
– to test minimum iterations (the loop must execute
not less than the number mentioned)
– to test maximum iterations (the loop mustn’t execute
more than the
number mentioned)
Example (Loop Fragment)
Reference Fragment
• It allows you to reuse or refer to a part of one sequence
diagram in another

• It helps manage the size of large sequencediagrams

• Include ‘ref’ in the name box of the frame to specify the


reference
fragment

• Mention the name of the sequence diagram being referred to


inside the frame
Example (Reference Fragment)
Sequence Diagram Common Mistakes
• Adding too much detail that makes it difficult to read the
diagram

• Obsolete sequence diagrams that are irrelevant when


compared to the interfaces, actual architectures of the
system

• Leaving no blank space between the use case text and the
message arrow

• Not considering the origins of message arrows carefully


Example of an Online ExamSystem
Example of a School Management System
Example of an Online Movie Ticket BookingSystem

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy