larman ch. 151 interaction diagram notation ch. 15
TRANSCRIPT
![Page 1: Larman ch. 151 Interaction Diagram Notation Ch. 15](https://reader036.vdocuments.site/reader036/viewer/2022062517/56649f225503460f94c3ac85/html5/thumbnails/1.jpg)
Larman ch. 15 1
Interaction DiagramNotation
Ch. 15
![Page 2: Larman ch. 151 Interaction Diagram Notation Ch. 15](https://reader036.vdocuments.site/reader036/viewer/2022062517/56649f225503460f94c3ac85/html5/thumbnails/2.jpg)
Larman ch. 15 2
Interaction Diagrams
• Illustrates how objects interact via messages• 2 diagram types:
– Sequence Diagram(fence format)
– Collaboration Diagram(graph or network) :ClassAInstance
:ClassBInstance
1: message2()
2: message3()
message1()
:ClassAInstance :ClassBInstance
message2()
message1()
message3()
![Page 3: Larman ch. 151 Interaction Diagram Notation Ch. 15](https://reader036.vdocuments.site/reader036/viewer/2022062517/56649f225503460f94c3ac85/html5/thumbnails/3.jpg)
Larman ch. 15 3
Collaboration Diagram
1: makePayment(cashTendered)
1.1: create(cashTendered)
: Register :Sale
:Payment
makePayment(cashTendered)
creation indicated with a"create" message
direction of message
first message
instance
first internal message
link line
parameter
![Page 4: Larman ch. 151 Interaction Diagram Notation Ch. 15](https://reader036.vdocuments.site/reader036/viewer/2022062517/56649f225503460f94c3ac85/html5/thumbnails/4.jpg)
Larman ch. 15 4
Sequence Diagram
: Register : Sale
makePayment(cashTendered)
makePayment(cashTendered)
: Paymentcreate(cashTendered)
an activation box showingthe focus of control
![Page 5: Larman ch. 151 Interaction Diagram Notation Ch. 15](https://reader036.vdocuments.site/reader036/viewer/2022062517/56649f225503460f94c3ac85/html5/thumbnails/5.jpg)
Larman ch. 15 5
Common interaction Diagram Notation
• Classes and Instances:
Sale :Sale s1: Sale
class instance named instance
![Page 6: Larman ch. 151 Interaction Diagram Notation Ch. 15](https://reader036.vdocuments.site/reader036/viewer/2022062517/56649f225503460f94c3ac85/html5/thumbnails/6.jpg)
Larman ch. 15 6
Common interaction Diagram Notation
• Basic Message Expression Syntax:return := message(parameter : parameterType) : returnType
spec := getProductSpec( id )
spec := getProductSpec( id : ItemID )
spec := getProductSpec( id : ItemID ) : ProductSpecification
![Page 7: Larman ch. 151 Interaction Diagram Notation Ch. 15](https://reader036.vdocuments.site/reader036/viewer/2022062517/56649f225503460f94c3ac85/html5/thumbnails/7.jpg)
Larman ch. 15 7
Basic Collaboration Diagram Notation
• Links:a connection path between two objects
1: makePayment(cashTendered)2: foo()
2.1: bar(): Register :Sale
link line
![Page 8: Larman ch. 151 Interaction Diagram Notation Ch. 15](https://reader036.vdocuments.site/reader036/viewer/2022062517/56649f225503460f94c3ac85/html5/thumbnails/8.jpg)
Larman ch. 15 8
Basic Collaboration Diagram Notation
• Messages:
• Messages to ’self’ or ’this’
1: msg2()2: msg3()3: msg4()
3.1: msg5(): Register :Sale
all messages flow on the same link
msg1()
: Register
msg1()
1: clear()
![Page 9: Larman ch. 151 Interaction Diagram Notation Ch. 15](https://reader036.vdocuments.site/reader036/viewer/2022062517/56649f225503460f94c3ac85/html5/thumbnails/9.jpg)
Larman ch. 15 9
Basic Collaboration Diagram Notation
• Creation of Instances:
1: create(cashier)
: Register :Sale {new}
create message, with optional initializing parameters. This willnormally be interpreted as a constructor call.
«create»1: make(cashier)
: Register :Sale {new}
if an unobvious creation message name is used, themessage may be stereotyped for clarity
![Page 10: Larman ch. 151 Interaction Diagram Notation Ch. 15](https://reader036.vdocuments.site/reader036/viewer/2022062517/56649f225503460f94c3ac85/html5/thumbnails/10.jpg)
Larman ch. 15 10
Basic Collaboration Diagram Notation
• Message number sequencing:
:ClassAmsg1() :ClassB1: msg2()
:ClassC
1.1: msg3()not numbered
legal numbering
![Page 11: Larman ch. 151 Interaction Diagram Notation Ch. 15](https://reader036.vdocuments.site/reader036/viewer/2022062517/56649f225503460f94c3ac85/html5/thumbnails/11.jpg)
Larman ch. 15 11
Basic Collaboration Diagram Notation
• Complex sequence numbering:
;ClassAmsg1() :ClassB1: msg2()
:ClassC
1.1: msg3()
2.1: msg5()
2: msg4()
:ClassD
2.2: msg6()
first second
fourth
sixth
fifth
third
![Page 12: Larman ch. 151 Interaction Diagram Notation Ch. 15](https://reader036.vdocuments.site/reader036/viewer/2022062517/56649f225503460f94c3ac85/html5/thumbnails/12.jpg)
Larman ch. 15 12
Basic Collaboration Diagram Notation
• Conditional Messages:
1 [ color = red ] : calculate(): Foo : Bar
message1()
conditional message, with test
![Page 13: Larman ch. 151 Interaction Diagram Notation Ch. 15](https://reader036.vdocuments.site/reader036/viewer/2022062517/56649f225503460f94c3ac85/html5/thumbnails/13.jpg)
Larman ch. 15 13
Basic Collaboration Diagram Notation
• Mutually Exclusive Conditional Paths:
1a [test1] : msg2()
:ClassA :ClassB
:ClassC
1a.1: msg3()
msg1()
:ClassD
1b [not test1] : msg4()
1b.1: msg5()
:ClassE
2: msg6()
unconditional aftereither msg2 or msg4 1a and 1b are mutually
exclusive conditional paths
![Page 14: Larman ch. 151 Interaction Diagram Notation Ch. 15](https://reader036.vdocuments.site/reader036/viewer/2022062517/56649f225503460f94c3ac85/html5/thumbnails/14.jpg)
Larman ch. 15 14
Basic Collaboration Diagram Notation
• Iteration or Looping:
1 * [i:=1..N]: num := nextInt(): SimulatorrunSimulation() : Random
iteration is indicated with a * and an optionaliteration clause following the sequence number
![Page 15: Larman ch. 151 Interaction Diagram Notation Ch. 15](https://reader036.vdocuments.site/reader036/viewer/2022062517/56649f225503460f94c3ac85/html5/thumbnails/15.jpg)
Larman ch. 15 15
Basic Collaboration Diagram Notation
• Iteration over a Collection:
1 *: st := getSubtotal(): Salet := getTotal()
double box indicates a multiobject (collection)
for example, a List object containing manySalesLineItem objects
*
:SalesLineItem:SalesLineItem
these two * symbols used together implyiteration over the multiobject and sending thegetSubtotal message to each member
![Page 16: Larman ch. 151 Interaction Diagram Notation Ch. 15](https://reader036.vdocuments.site/reader036/viewer/2022062517/56649f225503460f94c3ac85/html5/thumbnails/16.jpg)
Larman ch. 15 16
Basic Collaboration Diagram Notation
• Messages to a Class Object
: Foo
list := synchronizedList( aList )message1()
java.util.Collections
not underlined,therefore a class
message to class, or astatic method call
![Page 17: Larman ch. 151 Interaction Diagram Notation Ch. 15](https://reader036.vdocuments.site/reader036/viewer/2022062517/56649f225503460f94c3ac85/html5/thumbnails/17.jpg)
Larman ch. 15 17
Basic Sequence Diagram Notation
• Links:– Sequence diagrams do not show links (connection
paths between objects)
![Page 18: Larman ch. 151 Interaction Diagram Notation Ch. 15](https://reader036.vdocuments.site/reader036/viewer/2022062517/56649f225503460f94c3ac85/html5/thumbnails/18.jpg)
Larman ch. 15 18
Basic Sequence Diagram Notation
• Messages:
: Register : Sale
msg2()
msg3()
msg1()
msg4()
msg5()
![Page 19: Larman ch. 151 Interaction Diagram Notation Ch. 15](https://reader036.vdocuments.site/reader036/viewer/2022062517/56649f225503460f94c3ac85/html5/thumbnails/19.jpg)
Larman ch. 15 19
Basic Sequence Diagram Notation
• Messages – illustrating returns:
: Register : Sale
msg2()
msg3()
msg1()
msg4()
msg5()
![Page 20: Larman ch. 151 Interaction Diagram Notation Ch. 15](https://reader036.vdocuments.site/reader036/viewer/2022062517/56649f225503460f94c3ac85/html5/thumbnails/20.jpg)
Larman ch. 15 20
Basic Sequence Diagram Notation
• Messages to ’self’ or ’this’:
: Register
msg1()
clear()
![Page 21: Larman ch. 151 Interaction Diagram Notation Ch. 15](https://reader036.vdocuments.site/reader036/viewer/2022062517/56649f225503460f94c3ac85/html5/thumbnails/21.jpg)
Larman ch. 15 21
Basic Sequence Diagram Notation
• Creation of Instances:
: Register : Sale
makePayment(cashTendered)
: Paymentcreate(cashTendered)
authorize()
note that newly createdobjects are placed at theircreation "height"
an object lifeline shows the extent ofthe life of the object in the diagram
![Page 22: Larman ch. 151 Interaction Diagram Notation Ch. 15](https://reader036.vdocuments.site/reader036/viewer/2022062517/56649f225503460f94c3ac85/html5/thumbnails/22.jpg)
Larman ch. 15 22
Basic Sequence Diagram Notation
• Object lifelines and Object Destruction:
: Sale
: Paymentcreate(cashTendered)
...the «destroy» stereotypedmessage, with the largeX and short lifelineindicates explicit objectdestruction
«destroy» X
![Page 23: Larman ch. 151 Interaction Diagram Notation Ch. 15](https://reader036.vdocuments.site/reader036/viewer/2022062517/56649f225503460f94c3ac85/html5/thumbnails/23.jpg)
Larman ch. 15 23
Basic Sequence Diagram Notation
• Conditional Messages:
: Bar: Foo
[ color = red ] calculate()message1()
![Page 24: Larman ch. 151 Interaction Diagram Notation Ch. 15](https://reader036.vdocuments.site/reader036/viewer/2022062517/56649f225503460f94c3ac85/html5/thumbnails/24.jpg)
Larman ch. 15 24
Basic Sequence Diagram Notation
• Mutually Exclusive Conditional Messages:
: B: A
[ x < 10 ] calculate()message1()
: C
[ x > 15 ] calculate()
![Page 25: Larman ch. 151 Interaction Diagram Notation Ch. 15](https://reader036.vdocuments.site/reader036/viewer/2022062517/56649f225503460f94c3ac85/html5/thumbnails/25.jpg)
Larman ch. 15 25
Basic Sequence Diagram Notation
• Iteration for a single message:
: Simulator : Random
* [i:=1..N]: num := nextInt()
runSimulation()
![Page 26: Larman ch. 151 Interaction Diagram Notation Ch. 15](https://reader036.vdocuments.site/reader036/viewer/2022062517/56649f225503460f94c3ac85/html5/thumbnails/26.jpg)
Larman ch. 15 26
Basic Sequence Diagram Notation
• Iteration of a Series of Messages:
: Simulator : Random
hours := nextInt()
runSimulation()
: Programmer
work( hours )
* [i:=1..N]
eat()
![Page 27: Larman ch. 151 Interaction Diagram Notation Ch. 15](https://reader036.vdocuments.site/reader036/viewer/2022062517/56649f225503460f94c3ac85/html5/thumbnails/27.jpg)
Larman ch. 15 27
Basic Sequence Diagram Notation
• Iteration over a Collection:
: Sale
* : st := getSubtotal()
t := getTotal()
:SalesLineItem:SalesLineItem
![Page 28: Larman ch. 151 Interaction Diagram Notation Ch. 15](https://reader036.vdocuments.site/reader036/viewer/2022062517/56649f225503460f94c3ac85/html5/thumbnails/28.jpg)
Larman ch. 15 28
Basic Sequence Diagram Notation
• Messages to Class Objects
: Foo
list := synchronizedList( aList )message1()
java.util.Collections
not underlined,therefore a class
message to class, or astatic method call
![Page 29: Larman ch. 151 Interaction Diagram Notation Ch. 15](https://reader036.vdocuments.site/reader036/viewer/2022062517/56649f225503460f94c3ac85/html5/thumbnails/29.jpg)
Larman ch. 15 29
Interaction DiagramsSummary
Collaboration Diagram
• Graph/network format• Links• Time ordering by
message numbers
Sequence Diagram
• Fence format• No links• Time ordering from top to
bottom• Show the focus of control• May illustrate returns