UML Diagrams:
Sequence Diagrams
Outline
• The Requirements Model and the Analysis model
• Importance of Sequence Diagrams
• Rules of sequence diagrams
• Use Cases and Sequence Diagrams
• The System Sequence Diagrams
• The Vending Machine Example
• Other Examples
The Requirements Model and the
Analysis Model
Static Analysis
Dynamic Analysis
Functional/
Nonfunctional
Requirements
Use Case Diagrams/
Sequence Diagrams
(the system level)
- Class Diagrams
- State Diagrams/
Refined Sequence
Diagrams (The object
level)
The Requirements
Elicitation
Process
The Object-Oriented
Analysis
Process
Importance of Sequence Diagrams
• Depict object interactions in a given
scenario identified for a given Use Case
• Specify the messages passed between
objects using horizontal arrows including
messages to/from external actors
• Time increases from Top to bottom
Rules of Sequence Diagrams
• Sequence Initiation
updateStatus( )
Click Update Button
User
Object1:C1 Object2:C2
Rules of Sequence Diagrams
• Identify objects needed to support use case,
determine sequence of internal events following
the external initiating event
• Diagrams that are not initiated with an external
actor represent only a partial sequence
• Partial sequence diagrams should clearly identify
the actor initiated sequence diagrams from which
they are launched
Rules of Sequence Diagrams
• Messages specified on interactions can be
synchronous or asynchronous
updateStatus( )
Object1:C1 Object2:C2
calcRoute( )
route
Object1:C1 Object2:C2
Implicit Returns Explicit Return
Object3:C3
generateMessage( )
Synchronous call
Rules of Sequence Diagrams
Asynchronous call
asynchronous_Call ()
callBack ()
Object1:C1
{active}
Object2:C2
{active}
Rules of Sequence Diagrams
• Display operation names on call arrows
c:client
factory:
cmd_pktCToCHeaderFactory
header:
cmd_pktCToCCommandHeader
buildHeader( char * )
«create»
header
Rules of Sequence Diagrams
Compound and Simple Iteration
* [for all
Interfaces in
Container] Find( )
amMasterSI( )
setState( )
getInterfaceContainer()
* [for all Interfaces in Container] publishState() setOn( ) / setOff( )
{
:DiscreteFD
:DiscreteFD
:Interface
:Interface:InterfaceContainer:Subsystem :Resource
‘included’ sequence diagrams
Command Response
Command Request
Command Request
Command Response
<<includes>>
Process Command
Response sequence
<<includes>>
Process Command
Request sequence
Application Process
with CIF
CMM:process target:process
Showing alternate behavior in a sequence
diagram
validateCommand( )
issueCommand( )
User Application
[if valid command] routeCommand( )
[if invalid command] logError( )
display(status)
:CmdHandler :CmdValidater :CmdRouter :EventLog :StatusDialog
Showing Extension Point
validateCommand( )
routeCommand( )
display( status)
Extension Point
[invalid command]
abort command
request and send
system message
:StatusDialog:CmdRouter:CmdValidater:CmdHandler
issueCommand( )
User Application
Specifying Timing Requirements
a: Command
Create Transaction
b: Command
d: Response
Remove Transaction
c: Response
CMM : process target : process
User Application
{b.receiveTime ≤
a.sendTime + 50ms}
{d.receiveTime ≤
a.sendTime + 1s}
System Sequence Diagram
for Deposit Money Use Case
C u s t o m e r
M o n e y D e t e c t i o n
H a r d w a r e
C R T D i s p l a y
V e n d i n g M a c h i n e
C o n t r o l l e r
D e p o s i t M o n e y
[ I d l e S t a t e ]
D i s p l a y W e lc o m e
M e s s a g e
D i s p l a y A m o u n t
S e n d A m o u n t
P r o m p t f o r S e l e c t i o n
S t a r t T i m e r
[ I f T i m e r > 3 0 s e c o n d s a n d I n v a l i d o r N o S e l e c t i o n ]
R e t u r n M o n e y
M o n e y
D i s p e n s e r
S t o p
T i m e r[ I d l e S t a t e ]
D i s p l a y W e l c o m e
M e s s a g e
System Sequence Diagram
for Make Selection Use Case
C u s t o m e r
N u m e r ic K e y p a d C R T D is p la y
V e n d in g M a c h in e
C o n t r o lle r
M o n e y
D is p e n s e r
P r o d u c t
D is p e n s e r
P r o m p t
f o r
S e le c t io n
E n t e r S e le c t io n
D is p la y S e le c t io n
S e n d S e le c t io n
P r o d u c t
D a t a b a s e
I n q u ir e D a t a b a s e
[ if I n v a lid S e le c t io n ]
P r o m p t f o r A n o t h e r S e le c t io n
D is p e n s e P r o d u c t
D is p e n s e C a lc u la t e d
C h a n g e[ I d le S t a t e ]
D i s p la y W e lc o m e
M e s s a g e
N o t e : I n s u f f i c i e n t
m o n e y , s e l e c t i o n
n o t a v a i l a b l e
N o t e : I f
R e l e a s e - I n p u t
B u t t o n P r e s s e d s e e
C a n c e l l a t i o n
S e q u e n c e D i a g r a m
R e t u r n R e s p o n s e
V a lid a t e
U p d a t e D a t a b a s e
System Sequence Diagram
for Cancellation Use Case
C u s t o m e r
N u m e r ic K e y p a d C R T D is p la y
V e n d in g M a c h in e
C o n t r o lle r
M o n e y D is p e n s e r
P r o m p t
f o r
S e le c t io nR e le a s e - I n p u t
B u t t o n P r e s s e d
S e n d C a n c e lla t io n S ig n a l
[ I d le S t a t e ]
D is p la y W e lc o m e
M e s s a g e
R e t u r n M o n e y
System Sequence Diagram
for Update Database Use Case
M a i n t e n a n c e
O p e r a t o r
A ll H a r d w a r e
E x c e p t C R T D i s p la y
C R T D i s p la y
V e n d i n g M a c h i n e
C o n t r o l l e r
P r o d u c t
D a t a b a s e
W ir e le s s K e y b o a r d
P o w e r O n
S e n d A c t i v e S i g n a l
D is p la y P r o g r a m m in g
I n f o r m a t i o n
D is a b le
E n a b l e
S e n d U p d a t e C o m m a n d s
U p d a t e D a t a b a s e
P o w e r O f f
[ I d l e S t a t e ]
D is p l a y W e l c o m e I n f o r m a t i o n
D is p la y U p d a t e
C o m m a n d s
T e r m i n a t e U p d a t e M o d e
Other Examples of Sequence Diagrams
A Simple Example of Using UML2
• EXAMPLE: SATELLITE CONTROL
SYSTEM
A Simple Example Using UML2
• SATELLITE CONTROL SYSTEM
Architectural behavior

Sequense diagram

  • 1.
  • 2.
    Outline • The RequirementsModel and the Analysis model • Importance of Sequence Diagrams • Rules of sequence diagrams • Use Cases and Sequence Diagrams • The System Sequence Diagrams • The Vending Machine Example • Other Examples
  • 3.
    The Requirements Modeland the Analysis Model Static Analysis Dynamic Analysis Functional/ Nonfunctional Requirements Use Case Diagrams/ Sequence Diagrams (the system level) - Class Diagrams - State Diagrams/ Refined Sequence Diagrams (The object level) The Requirements Elicitation Process The Object-Oriented Analysis Process
  • 4.
    Importance of SequenceDiagrams • Depict object interactions in a given scenario identified for a given Use Case • Specify the messages passed between objects using horizontal arrows including messages to/from external actors • Time increases from Top to bottom
  • 5.
    Rules of SequenceDiagrams • Sequence Initiation updateStatus( ) Click Update Button User Object1:C1 Object2:C2
  • 6.
    Rules of SequenceDiagrams • Identify objects needed to support use case, determine sequence of internal events following the external initiating event • Diagrams that are not initiated with an external actor represent only a partial sequence • Partial sequence diagrams should clearly identify the actor initiated sequence diagrams from which they are launched
  • 7.
    Rules of SequenceDiagrams • Messages specified on interactions can be synchronous or asynchronous updateStatus( ) Object1:C1 Object2:C2 calcRoute( ) route Object1:C1 Object2:C2 Implicit Returns Explicit Return Object3:C3 generateMessage( ) Synchronous call
  • 8.
    Rules of SequenceDiagrams Asynchronous call asynchronous_Call () callBack () Object1:C1 {active} Object2:C2 {active}
  • 9.
    Rules of SequenceDiagrams • Display operation names on call arrows c:client factory: cmd_pktCToCHeaderFactory header: cmd_pktCToCCommandHeader buildHeader( char * ) «create» header
  • 10.
    Rules of SequenceDiagrams Compound and Simple Iteration * [for all Interfaces in Container] Find( ) amMasterSI( ) setState( ) getInterfaceContainer() * [for all Interfaces in Container] publishState() setOn( ) / setOff( ) { :DiscreteFD :DiscreteFD :Interface :Interface:InterfaceContainer:Subsystem :Resource
  • 11.
    ‘included’ sequence diagrams CommandResponse Command Request Command Request Command Response <<includes>> Process Command Response sequence <<includes>> Process Command Request sequence Application Process with CIF CMM:process target:process
  • 12.
    Showing alternate behaviorin a sequence diagram validateCommand( ) issueCommand( ) User Application [if valid command] routeCommand( ) [if invalid command] logError( ) display(status) :CmdHandler :CmdValidater :CmdRouter :EventLog :StatusDialog
  • 13.
    Showing Extension Point validateCommand() routeCommand( ) display( status) Extension Point [invalid command] abort command request and send system message :StatusDialog:CmdRouter:CmdValidater:CmdHandler issueCommand( ) User Application
  • 14.
    Specifying Timing Requirements a:Command Create Transaction b: Command d: Response Remove Transaction c: Response CMM : process target : process User Application {b.receiveTime ≤ a.sendTime + 50ms} {d.receiveTime ≤ a.sendTime + 1s}
  • 15.
    System Sequence Diagram forDeposit Money Use Case C u s t o m e r M o n e y D e t e c t i o n H a r d w a r e C R T D i s p l a y V e n d i n g M a c h i n e C o n t r o l l e r D e p o s i t M o n e y [ I d l e S t a t e ] D i s p l a y W e lc o m e M e s s a g e D i s p l a y A m o u n t S e n d A m o u n t P r o m p t f o r S e l e c t i o n S t a r t T i m e r [ I f T i m e r > 3 0 s e c o n d s a n d I n v a l i d o r N o S e l e c t i o n ] R e t u r n M o n e y M o n e y D i s p e n s e r S t o p T i m e r[ I d l e S t a t e ] D i s p l a y W e l c o m e M e s s a g e
  • 16.
    System Sequence Diagram forMake Selection Use Case C u s t o m e r N u m e r ic K e y p a d C R T D is p la y V e n d in g M a c h in e C o n t r o lle r M o n e y D is p e n s e r P r o d u c t D is p e n s e r P r o m p t f o r S e le c t io n E n t e r S e le c t io n D is p la y S e le c t io n S e n d S e le c t io n P r o d u c t D a t a b a s e I n q u ir e D a t a b a s e [ if I n v a lid S e le c t io n ] P r o m p t f o r A n o t h e r S e le c t io n D is p e n s e P r o d u c t D is p e n s e C a lc u la t e d C h a n g e[ I d le S t a t e ] D i s p la y W e lc o m e M e s s a g e N o t e : I n s u f f i c i e n t m o n e y , s e l e c t i o n n o t a v a i l a b l e N o t e : I f R e l e a s e - I n p u t B u t t o n P r e s s e d s e e C a n c e l l a t i o n S e q u e n c e D i a g r a m R e t u r n R e s p o n s e V a lid a t e U p d a t e D a t a b a s e
  • 17.
    System Sequence Diagram forCancellation Use Case C u s t o m e r N u m e r ic K e y p a d C R T D is p la y V e n d in g M a c h in e C o n t r o lle r M o n e y D is p e n s e r P r o m p t f o r S e le c t io nR e le a s e - I n p u t B u t t o n P r e s s e d S e n d C a n c e lla t io n S ig n a l [ I d le S t a t e ] D is p la y W e lc o m e M e s s a g e R e t u r n M o n e y
  • 18.
    System Sequence Diagram forUpdate Database Use Case M a i n t e n a n c e O p e r a t o r A ll H a r d w a r e E x c e p t C R T D i s p la y C R T D i s p la y V e n d i n g M a c h i n e C o n t r o l l e r P r o d u c t D a t a b a s e W ir e le s s K e y b o a r d P o w e r O n S e n d A c t i v e S i g n a l D is p la y P r o g r a m m in g I n f o r m a t i o n D is a b le E n a b l e S e n d U p d a t e C o m m a n d s U p d a t e D a t a b a s e P o w e r O f f [ I d l e S t a t e ] D is p l a y W e l c o m e I n f o r m a t i o n D is p la y U p d a t e C o m m a n d s T e r m i n a t e U p d a t e M o d e
  • 19.
    Other Examples ofSequence Diagrams
  • 20.
    A Simple Exampleof Using UML2 • EXAMPLE: SATELLITE CONTROL SYSTEM
  • 21.
    A Simple ExampleUsing UML2 • SATELLITE CONTROL SYSTEM Architectural behavior