Professional Documents
Culture Documents
Sequence Diagram: Object Oriented Analysis and Design
Sequence Diagram: Object Oriented Analysis and Design
2
Sequence Diagram Frames
3
Lifelines
4
Lifeline Creation and Destruction
5
Lifelines Example
sd UseComponent
client supplier
create
:Component
destroy
X
6
Lifeline Identifier Format
7
Lifeline Identifier Examples
• player[i] : Player
• player[i]
• : Player
• board
8
Self
get(item)
remove(item)
destroy
X
9
Messages and Message Arrows
• Synchronous—The sender
suspends execution until the
message is complete
• Asynchronous—The sender
continues execution after
sending the message
• Synchronous message return
or instance creation
10
Message Arrow Example
sd FindItem
client searcher
find(description)
foundMatch(description)
fetch(description)
clone(item)
result
11
Message Specification Format
12
Message Specification Examples
• hello
• hello()
• msg = getMessage( helloMessage )
• x = sin( a/2 )
• x = sin( angle = a/2 )
• trim( result = aString )
• Note that assigning a value to a parameter and
assigning a returned value to a variable cannot be
distinguished.
13
Execution Occurrences
14
Execution Occurrence Example
sd ButtonPress
press
actionPerformed(event)
toggle
getState()
15
Sequence Diagram Heuristics 1
16
Sequence Diagram Heuristics 2
17
Sequence Diagram Heuristics 3
18
Using Sequence Diagrams
19
ELEMENTS
20
Elements (extended)
1. Activation:
• The start of the vertical
rectangle, the activation bar
2. Deactivation:
• The end of the vertical
rectangle, the activation bar
3. Timeout event:
• Typically signified by a full
arrowhead with a small clock
face or circle on the line
4. Asynchronous event:
• Typically signified by a stick
arrowhead
5. Object termination
symbolized by an X
21
-: EXAMPLES :-
22
On-Line Stockbroker
– Use Cases for Stock Purchase
Successful purchase
customer
Unsuccessful purchase attempt
23
On-Line Stockbroker Scenarios
24
Description of Scenario 1
• User logs in
• Selects the stock he wishes to purchase
• Specifies how much stock he wants to buy
• Specifies the limits on the price he is willing to pay
• Places order
• System responds with details of successful purchase
25
Class Diagram
Customer
Stockbroker System SecuritiesExchange
26
Sequence Diagram for Stock Purchase
27
Description of Scenario 2:
Un-successful purchase of stock – inadequate funds available
1. User logs in
2. Select stock he wishes to purchase
3. Specifies how much stock he wants to buy
4. Specifies limits on the price he is willing to pay
5. Place order
6. Order rejected due to lack of funds
7. Delete order
28
Un-successful purchase of stock – inadequate funds available
29
Electric Kettle Design Scenario 1
kettle boils after cut out due to no water
User
Boils water
30
Scenario 1: Boil Water but – no water
31
Develop relevant Class Diagrams
We need switch, water, heating element, cut-out
temperature Provides
Cut-out temperature heat to
Cut-out
reset
32
We need Water and Switch
liquid
Boiling point
Latent heat of vaporisation
boiling
Switch
Water State = [ On or Off]
33
Sequence Diagram for Scenario 1
User
{Loop until cut-out
Switch on Activate or boils}heat
{loop} update
temperature
{Loop} update
temperature
Check cut-
out
temperature
34
Update Scenario 1: Boil Water but – no water
35