11-UML Modeling-Design Sequence Diagram.pptx
11-UML Modeling-Design Sequence Diagram.pptx
three
Sequence diagrams
8
public class A
{
private B myB = new B();
public void doOne()
{
myB.doTwo();
myB.doThree();
}
// …
}
Illustrating Classes and Instances
9
11
Two ways to show a return result from a
message
12
Two ways to show a return result from a
message
:Register :Sale
report
theReport = report
Variant A
:Register :Sale
report
report
Variant B theReport
Modeling (Synchronous) Messages
a message whose sender will not be typical synchronous message
specified shown with a filled-arrow
:Register :Sale
report
getDate
Date
execution specification bar
indicates focus of control
getSale
Synchronous and Asynchronous Messages
First message is a synchronous message (denoted by the solid arrowhead)
complete with an implicit return message; the second message is asynchronous
(denoted by line arrowhead), and the third is the asynchronous return message
(denoted by the dashed line).
: :
Messages to "self" or "this"
16
: :
Diagram Frames in UML Sequence Diagrams
• To support conditional and looping constructs (among many other things), the
UML uses frames.
• Frames are regions or fragments of the diagrams; they have an operator or label
(such as loop) and a guard (conditional clause).
20
Frame Operator
21
Frame
Operator Meaning
alt Alternative fragment for mutual exclusion conditional logic expressed
in the guards.
loop Loop fragment while guard is true. Can also write loop(n) to indicate
looping n times.
st = getSubTotal
Modeling task: Get the sum of all sales that happened before a
specific date.
Use a UML opt frame to model the sending of a message
if the guard condition matches.
: Register sales[i] : Sale
r = getTotal(endDate)
• Object-Oriented
rd
Analysis and Design with Applications, Grady Booch et al.,
3 Edition, Pearson, 2007.