Presentation is loading. Please wait.

Presentation is loading. Please wait.

UML Interaction Diagrams

Similar presentations


Presentation on theme: "UML Interaction Diagrams"— Presentation transcript:

1 UML Interaction Diagrams
Ch. 15

2 Interaction Diagram Notation

3 Introduction Interaction diagrams illustrate how objects interact via messages. Collaboration diagrams illustrate object interactions in a graph or network format. message1( ) :ClassAInstance 1: message2() 2: message3() :ClassBInstance

4 Sequence vs Collaboration Diagrams
:ClassAInstance :ClassBInstance message1( ) :ClassAInstance message1() message2() 1: message2() 2: message3() What is the difference of collaboration vs sequence diagrams? For which components of a sw project do we draw a sequence diagram? For which components of a sw project do we draw a collaboration diagram? Collab: more for whiteboard vertical/horizontal expansion Spend time doing dynamic modeling! message3() :ClassBInstance

5 Example Collaboration Diagram: makePayment
direction of message first internal message makePayment(cash Tendered) :Register 1: makePayment(cash Tendered) :Sale parameter link line 1.1: create(cash Tendered) first message instance :Payment object creation

6 How to Read the makePayment Collaboration Diagram
The message makePayment is sent to an instance of Register. The sender is not identified. The Register instance sends the makePayment message to a Sale instance. The Sale instance creates an instance of a Payment. makePayment(cashTendered) :Register 1: makePayment(cashTendered) :Sale 1.1: create(cashTendered) :Payment

7 Example Sequence Diagram: makePayment
:Register :Sale makePayment (cashTendered) makePayment (cashTendered) create (cashTendered) :Payment

8 Illustrating Classes and Instances
To show an instance of a class, the regular class box graphic symbol is used, but the name is underlined. Additionally a class name should be preceded by a colon. An instance name can be used to uniquely identify the instance. Sale Class :Sale Instance s1:Sale Named instance

9 Messages to “self” or “this”
A message can be sent from an object to itself. This is illustrated by a link to itself, with messages flowing along the link. msg1() :Register 1: clear()

10 Creation of Instances The language independent creation message is create, being sent to the instance being created. The create message may include parameters, indicating passing of initial values. msg1 ( ) 1: create (cashier) :Register :Sale newly created instance

11 Creation of Instances An object lifeline shows the extend of the life of an object in the diagram. Note that newly created objects are placed at their creation height. :Register :Sale makePayment(…) makePayment(…) create(…) :Payment

12 Lifelines Synchronous vs asynchronous messages

13 Asynchronous vs synchronous calls
Async: not block or wait for response, used in multithreaded java

14 Return Values

15 Conditional Messages :A :B message1() [color=red] calculate()

16 Conditionals

17 Conditional Messages A conditional message is shown by following a sequence number with a conditional clause in square brackets, similar to the iteration clause. The message is sent only if the clause evaluates to true. msg1 ( ) 1: [new sale] create (cashier) :Register :Sale Link: connection path between two objects (straight line in comm diag.)

18 Mutually Exclusive Conditional Paths
1a and 1b are mutually exclusive conditional paths. Both are sequence number 1 since either could be the first internal message. unconditional after either msg2() or msg4() :ClassE 2: msg6() msg1 ( ) 1a: [test1] msg2() :ClassA :ClassB 1b: [not test1] msg4() 1a.1: msg3() :ClassD :ClassC 1b.1: msg5()

19 Iteration or Looping Iteration; Recurrence values omitted Iteration is indicated by following the sequence number with a star * This expresses that the message is being sent repeatedly, in a loop, to the receiver. It is also possible to include an iteration clause indicating the recurrence values. msg1( ) 1*: li := nextLineItem(): SalesLineItem :Register :Sale Iteration clause msg1( ) 1*: [i :=1..10] li := nextLineItem(): SalesLineItem :Register :Sale


Download ppt "UML Interaction Diagrams"

Similar presentations


Ads by Google