Sequence diagram

Graphical Systems Modeling
with UML / SysML
Sequence diagrams
© Piotr Ciskowski
State machine diagrams – lecture plan:
o
Overview
GO
o
Basic elements
GO
o
Advanced elements
GO
o
Combined fragments
GO
o
Summary
GO
o
Examples
GO
Perspectives - views:
architecture
• class diagram
• object diagram
• composite structure
diagram
• package diagram
Logical
view
Dynamic
View
behavior
• sequence diagram
• activity diagram
• state machine diagram
• interaction overview
diagram
• communication diagram
• timing diagram
• package diagram
Use case
view
system scope
& functionality
• use case diagram
Deployment
View
• package diagram
Implementation
View
software
• component diagram
• package diagram
hardware
• deployment diagram
• package diagram
Sequence diagram
•
describes interactions between instances
as sequences of messages passed between them
•
documents functionality of a use case
Sequence diagram
•
describes interactions between instances
as sequences of messages passed between them
•
documents functionality of a use case
•
shows:
 flow of control
 order and location of performed operations
 exchange of messages between objects – chronologically
 logic of methods and services
Sequence diagram
•
describes interactions between instances
as sequences of messages passed between them
•
documents functionality of a use case
•
shows:
 flow of control
 order and location of performed operations
 exchange of messages between objects – chronologically
 logic of methods and services
•
close to code
Sequence diagram
•
describes interactions between instances
as sequences of messages passed between them
•
documents functionality of a use case
•
shows:
 flow of control
 order and location of performed operations
 exchange of messages between objects – chronologically
 logic of methods and services
•
close to code
•
•
horizontally - classifiers’ instances
vertically
- time
Sequence diagram
•
describes interactions between instances
as sequences of messages passed between them
•
documents functionality of a use case
•
shows:
 flow of control
 order and location of performed operations
 exchange of messages between objects – chronologically
 logic of methods and services
•
close to code
•
•
horizontally - classifiers’ instances
vertically
- time
- statics
- dynamics
Sequence diagram
•
types of diagrams – levels of detail / abstraction:
 conceptual
- general scope
- evident interactions
Sequence diagram
•
types of diagrams – levels of detail / abstraction:
 conceptual
- general scope
- evident interactions
 implementational
 instance
-
very precise
all types of elements
main flow and all alternative flows
complete specification
for programmers / CASE tools
- implementational for a certain scenario
SEQUENCE DIAGRAM BASIC ELEMENTS
Basic elements:
–
objects, actors
(classifiers’ instances)
–
lifelines
image: Sparx Systems – UML 2 Tutorial
Basic elements:
–
objects, actors
(classifiers’ instances)
–
lifelines
–
messages
Basic elements:
–
objects, actors
(classifiers’ instances)
–
lifelines
–
messages
–
activation
- focus of control
- object active / inactive
Basic elements:
–
objects, actors
(classifiers’ instances)
–
lifelines
–
messages
image: Wikipedia
Basic elements:
–
objects, actor, lifelines, messages:
PINpad
Screen
ATMinterface
ChipCard
Client
getPIN()
enterPIN
verifyPIN()
showOperations()
checkBalance
checkAccountBalance()
showBalance()
BankSystem
SEQUENCE DIAGRAM ADVANCED ELEMENTS
Advanced elements
•
on detailed implementation diagrams:
–
–
–
–
–
–
–
–
different types of messages
creating and destroying objects
conditions
messages to self (self messages)
duration and time constraints
combined fragments
interaction uses
gates
Advanced elements
MESSAGES
Messages
•
•
•
•
synchronous call
asynchronous call
asynchronous signal
reply
image: Sparx Systems – UML 2 Tutorial
Messages
•
•
•
•
synchronous call
asynchronous call
asynchronous signal
reply
•
self
image: Sparx Systems – UML 2 Tutorial
Messages
•
•
•
•
synchronous call
asynchronous call
asynchronous signal
reply
•
self
•
•
create
delete
image: Sparx Systems – UML 2 Tutorial
Messages
•
•
•
•
synchronous call
asynchronous call
asynchronous signal
reply
•
self
•
•
create
delete
image: www.uml-diagrams.org
Messages
•
•
•
•
synchronous call
asynchronous call
asynchronous signal
reply
•
self
•
•
create
delete
 lost
 found
image: Sparx Systems – UML 2 Tutorial
Advanced elements
OTHER ELEMENTS
Other elements
•
conditions
- mesage executed if condition satisfied
- usually one message – one condition
IAuction
Buyer
[bidPrice > minBidPrice] : joinAuction()
example based on: Wrycza et al., Język UML 2.0 w modelowaniu… (modified)
Other elements
•
conditions
•
iterations
- multiple execution
* < operation >
* [ < iteration specification > ] < operation >
IProjectManager
WorkerDatabase
*[worker := 1..n] : assignSpecialist()
example based on: Wrycza et al., Język UML 2.0 w modelowaniu… (modified)
Other elements
•
conditions
•
iterations
•
forks
- at least two disjoint conditions
Seller
IUserPanel
ProductCatalogue
cancelAuction(reason)
[reason = withdrawArticle] : deleteArticle()
[reason = cancelAcution] : endAuction()
example based on: Wrycza et al., Język UML 2.0 w modelowaniu… (modified)
Auction
Other elements
•
forks
- at least two disjoint conditions
- with receiver’s lifeline split
CFDcontract
Broker
Bank
Buyer
closePosition()
updateValue()
[currentValue > nominalValue]:closePosition()
transferProfit()
[currentValue < nominalValue]:closePosition()
deductLoss()
confirmClosedPosition()
transferDeposit()
example based on: Wrycza et al., Język UML 2.0 w modelowaniu… (modified)
Other elements
•
conditions
•
iterations
•
forks
•
constraints
(time & duration)
image: Sparx Systems – UML 2 Tutorial
Advanced elements
COMBINED FRAGMENTS
Combined fragments
•
combined fragment
-
part of sequence diagram
enclosed in a frame
executed under specific circumstances
-
adds procedural logic
Combined fragments
•
combined fragment
-
part of sequence diagram
enclosed in a frame
executed under specific circumstances
-
adds procedural logic
•
operator
- how to interpret
•
operand
- what to do
Combined fragments
–
alt
image: www.uml-diagrams-org
- alternative
- if–then-else
- switch
Combined fragments
–
opt
image: www.uml-diagrams-org
- option
- alt with only one operand
Combined fragments
–
break
image: www.uml-diagrams-org
- breaking or exceptional scenario
- performed instead of other interactions
Combined fragments
–
loop
loop (n)
loop (min,max)
loop
images: www.uml-diagrams-org
- iteration
Combined fragments
–
neg
image: www.uml-diagrams-org
- invalid series of messages
Combined fragments
–
par
image: www.uml-diagrams-org
- parallel, concurrent processing
Combined fragments
–
par
image: www.uml-diagrams-org
- simplified notation
Combined fragments
–
critical
image: www.uml-diagrams-org
- critical section
- highest priority
- object „reservation”
Combined fragments
–
consider - ignore
consider { <messages> }
ignore { <messages> }
images: www.uml-diagrams-org
Combined fragments
–
strict
image: www.uml-diagrams-org
- strict order (sequencing)
Combined fragments
–
seq
image: www.uml-diagrams-org
- weak sequencing
Combined fragments
–
ref
images: www.uml-diagrams-org
- other interaction use
Combined fragments:
–
–
–
–
–
–
–
–
–
–
alt
opt
break
loop
neg
par
critical
consider, ignore
strict, seq
ref
-
alternative
option
breaking or exceptional scenario
iteration
invalid actions
parallel processing
critical section, highest priority
- strict order, weak sequencing
- reference to other interaction
SUMMARY
Sequence diagram
Summary:
image: www.uml-diagrams-org
Sequence diagram
Steps:
1. analyze use cas scenario
2. identify classifiers to take part in the interaction
3. create conceptual diagram:
–
–
–
classifiers’ instances – horizontally
ordered messages - vertically
execution boxes
4. create implementation diagram:
–
all other details, advanced elements and full specifications needed
5. create instance diagram
EXAMPLES
Examples for discussion
Facebook User Authentication in a Web application
source: www.uml-diagrams.org
Examples
…
source: www.uml-diagrams.org
more examples at www.uml-diagrams.org:
•
•
Online Bookshop
Submit Comments to Pluck using AJAX
Examples for discussion
Collaboration „Rent item”
source: www.tracemodeler.com