UML Interaction Diagrams Ch 15 Interaction Diagram Notation

  • Slides: 19
Download presentation
UML Interaction Diagrams Ch. 15

UML Interaction Diagrams Ch. 15

Interaction Diagram Notation 2

Interaction Diagram Notation 2

Introduction • Interaction diagrams illustrate how objects interact via messages. • Collaboration diagrams illustrate

Introduction • Interaction diagrams illustrate how objects interact via messages. • Collaboration diagrams illustrate object interactions in a graph or network format. message 1( ) : Class. AInstance 1: message 2() 2: message 3() : Class. BInstance 3

Sequence vs Collaboration Diagrams : Class. AInstance : Class. BInstance message 1() message 1(

Sequence vs Collaboration Diagrams : Class. AInstance : Class. BInstance message 1() message 1( ) : Class. AInstance message 2() message 3() 1: message 2() 2: message 3() : Class. BInstance 4

Example Collaboration Diagram: make. Payment direction of message make. Payment(cash Tendered) : Register parameter

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

How to Read the make. Payment Collaboration Diagram make. Payment(cash. Tendered) : Register 1:

How to Read the make. Payment Collaboration Diagram make. Payment(cash. Tendered) : Register 1: make. Payment(cash. Tendered) : Sale 1. 1: create(cash. Tendered) 1. The message make. Payment is sent to an instance of Register. The sender is not identified. 2. The Register instance sends the make. Payment message to a Sale instance. 3. The Sale instance creates an instance of a Payment. : Payment 6

Example Sequence Diagram: make. Payment : Register : Sale make. Payment (cash. Tendered) create

Example Sequence Diagram: make. Payment : Register : Sale make. Payment (cash. Tendered) create (cash. Tendered) : Payment 7

Illustrating Classes and Instances Sale Class : Sale Instance s 1: Sale Named instance

Illustrating Classes and Instances Sale Class : Sale Instance s 1: Sale Named instance • 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. 8

Messages to “self” or “this” msg 1() : Register • A message can be

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

Creation of Instances msg 1 ( ) : Register 1: create (cashier) : Sale

Creation of Instances msg 1 ( ) : Register 1: create (cashier) : Sale newly created instance • 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. 10

Creation of Instances : Register : Sale make. Payment(…) create(…) : Payment • An

Creation of Instances : Register : Sale make. Payment(…) create(…) : Payment • 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. 11

Lifelines

Lifelines

Asynchronous vs synchronous calls

Asynchronous vs synchronous calls

Return Values

Return Values

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

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

Conditionals

Conditionals

Conditional Messages msg 1 ( ) : Register 1: [new sale] create (cashier) :

Conditional Messages msg 1 ( ) : Register 1: [new sale] create (cashier) : Sale • 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. 17

Mutually Exclusive Conditional Paths unconditional after either msg 2() or msg 4() 1 a

Mutually Exclusive Conditional Paths unconditional after either msg 2() or msg 4() 1 a and 1 b are mutually exclusive conditional paths. Both are sequence number 1 since either could be the first internal message. : Class. E 2: msg 6() msg 1 ( ) : Class. A 1 a: [test 1] msg 2() 1 b: [not test 1] msg 4() : Class. D 1 b. 1: msg 5() : Class. B 1 a. 1: msg 3() : Class. C 18

Iteration or Looping msg 1( ) : Register Iteration; Recurrence values omitted 1*: li

Iteration or Looping msg 1( ) : Register Iteration; Recurrence values omitted 1*: li : = next. Line. Item(): Sales. Line. Item msg 1( ) : Sale • 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. Iteration clause 1*: [i : =1. . 10] li : = next. Line. Item(): Sales. Line. Item : Register • Iteration is indicated by following the sequence number with a star * : Sale 19