+ All Categories
Home > Documents > Interaction Diagrams - Chapter 15 Describe/illustrate sequence of message exchanges among objects...

Interaction Diagrams - Chapter 15 Describe/illustrate sequence of message exchanges among objects...

Date post: 19-Dec-2015
Category:
View: 215 times
Download: 1 times
Share this document with a friend
21
Interaction Diagrams - Chapter 15 Describe/illustrate sequence of message exchanges among objects •show the flow of control across many objects •used to illustrate a use case, a scenario, ... Types •Collaboration diagram •Sequence diagram
Transcript
Page 1: Interaction Diagrams - Chapter 15 Describe/illustrate sequence of message exchanges among objects show the flow of control across many objects used to.

Interaction Diagrams - Chapter 15

Describe/illustrate sequence of message exchanges among objects

•show the flow of control across many objects

•used to illustrate a use case, a scenario, ...

Types

•Collaboration diagram

•Sequence diagram

Page 2: Interaction Diagrams - Chapter 15 Describe/illustrate sequence of message exchanges among objects show the flow of control across many objects used to.

Interaction Diagrams

Message

•asynchronous or synchronous

•components

•numbered (collaboration diagram)

•guard

•name

•parameter list

•name is mandatory ... others as required

Page 3: Interaction Diagrams - Chapter 15 Describe/illustrate sequence of message exchanges among objects show the flow of control across many objects used to.

Interaction Diagrams

• Synchronous vs asynchronous messages

• We will assume (at first) that all messages are synchronous:

• if object A sends a message to object B then A is suspended

• object B gains control, and B begins to compute

• object A waits until B responds (i.e. B sends a message back to A)

•When an asynchronous message is sent from A to B, A does not pause and wait for B to finish … results in multiple threads of control.

Page 4: Interaction Diagrams - Chapter 15 Describe/illustrate sequence of message exchanges among objects show the flow of control across many objects used to.

Interaction Diagrams

Synchronous messages:

•control, or the ability to compute, is gained by holding a token that is passed with a message

• consider that there is an activation stack:

• when object A sends a message to object B, object B goes on to the top of the stack and it can compute. If B responds to A then B is popped from the stack and A, being at the top, begins to compute

Page 5: Interaction Diagrams - Chapter 15 Describe/illustrate sequence of message exchanges among objects show the flow of control across many objects used to.

Collaboration Diagram

•Objects are represented similarly to classes in a class model … relationships are indicated clearly

•Objects may be named or unnamed

•Timing is understood by the numbering scheme. We use a nested decimal numbering to indicate the order in which messages are sent

•Many messages may be sent across one link

Page 6: Interaction Diagrams - Chapter 15 Describe/illustrate sequence of message exchanges among objects show the flow of control across many objects used to.

Figure 15.3 Collaboration diagram for makePayment

Page 7: Interaction Diagrams - Chapter 15 Describe/illustrate sequence of message exchanges among objects show the flow of control across many objects used to.

Figure 15.7 Messages

Page 8: Interaction Diagrams - Chapter 15 Describe/illustrate sequence of message exchanges among objects show the flow of control across many objects used to.

Figure 15.8 Message to ‘this’

Page 9: Interaction Diagrams - Chapter 15 Describe/illustrate sequence of message exchanges among objects show the flow of control across many objects used to.

Figure 15.9 Instance creation

Page 10: Interaction Diagrams - Chapter 15 Describe/illustrate sequence of message exchanges among objects show the flow of control across many objects used to.

Figure 15.10 Sequence Numbering

Page 11: Interaction Diagrams - Chapter 15 Describe/illustrate sequence of message exchanges among objects show the flow of control across many objects used to.

Figure 15.11 Complex numbering

Page 12: Interaction Diagrams - Chapter 15 Describe/illustrate sequence of message exchanges among objects show the flow of control across many objects used to.

Figure 15.12 Conditional Message

Page 13: Interaction Diagrams - Chapter 15 Describe/illustrate sequence of message exchanges among objects show the flow of control across many objects used to.

Figure 15.13 Mutually exclusive messages

Page 14: Interaction Diagrams - Chapter 15 Describe/illustrate sequence of message exchanges among objects show the flow of control across many objects used to.

Figure 15.14 Iteration

Page 15: Interaction Diagrams - Chapter 15 Describe/illustrate sequence of message exchanges among objects show the flow of control across many objects used to.

Figure 15.15 Iteration over a multiobject

Page 16: Interaction Diagrams - Chapter 15 Describe/illustrate sequence of message exchanges among objects show the flow of control across many objects used to.

Figure 15.16 Messages to a class itself, not an object

Page 17: Interaction Diagrams - Chapter 15 Describe/illustrate sequence of message exchanges among objects show the flow of control across many objects used to.

Collaboration Diagram - example

Suppose we have classes for POrder, Customer, LineItem, Product with the following class model

POrder

LineItem Product

Customer1

10..*0..*

1

0..*

We want to exhibit how objects of these classes communicate in order for the POrder to learn its value

Page 18: Interaction Diagrams - Chapter 15 Describe/illustrate sequence of message exchanges among objects show the flow of control across many objects used to.

Collaboration Diagram - example

Suppose

•POrder does not know its value.

•To determine its value it must ask each of its line items “what are you worth?”, and then ask the customer “what discount do you get”.

•Each line doesn’t remember the corresponding products price and so it must interrogate the product to determine the price

POrder

LineItem Product

Customer1

10..*0..*

1

0..*

Page 19: Interaction Diagrams - Chapter 15 Describe/illustrate sequence of message exchanges among objects show the flow of control across many objects used to.

Collaboration Diagram

128937:POrder

line1:LineItem TYZMonitor:Product

line2:LineItem OptMouseX :Product

JonesSupply:Customer

1:cost:=reportTotal()

1.1:price:=reportPrice()

2:reportTotal()

2.1:price:=reportPrice()

3:discount:=reportDiscount()

reportTotal()

Given that the objects below are involved, we show them along with the basic associations

Since these are objects, not classes, there are no multiplicities

Some message starts things off

Page 20: Interaction Diagrams - Chapter 15 Describe/illustrate sequence of message exchanges among objects show the flow of control across many objects used to.

Collaboration Diagram

•Use the diagramming technique to show the complexity you need to understand or represent

•Example: consider the creation of the lines of a Purchase Order, and where

•we are checking for adequate stock on hand•we reorder if we fall below a reorder quantity - a reorder item line is created•if there’s enough on hand, a delivery line item gets created and quantity on hand must be decremented

Page 21: Interaction Diagrams - Chapter 15 Describe/illustrate sequence of message exchanges among objects show the flow of control across many objects used to.

Collaboration Diagram - example

128937:POrder

:LineItem

:DeliveryItem {new}

1*[for all order lines]: prepare()

1.1:reportPrice()1.2:[hasStock]:=remove()

1.2.1:needsToReorder:=needToReorder()

1.2.2:[needsToReorder]:create1.3:[hasStock]:=create

:Product

:ReorderItem {new}


Recommended