Top Banner
Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College
33

Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.

Jan 04, 2016

Download

Documents

Clare Houston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.

Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005

Interaction and Communication DiagramsPatrick BaileyKeith Vander LindenCalvin College

Page 2: Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.

2

Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005

Interaction diagrams describe how groups of objects collaborate in some behavior. The UML defines several forms of interaction diagram, of which the most common is the sequence diagram.

Ref: Martin Fowler – UML Distilled, 3rd Edition

Page 3: Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.

3

Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005

You should use sequence diagrams when you want to look at how several objects interact with each other within a single use case. Sequence diagrams are good at showing collaborations among the objects; they are not so good at precise definition of the behavior.

Sequence Diagrams

Ref: Martin Fowler – UML Distilled, 3rd Edition

Page 4: Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.

4

Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005

● Analyze and design scenarios between objects.

● Refine object definition and behavior.● Executable representation● Basis for test cases

Key Benefits Summarize

Page 5: Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.

5

Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005

What’s in a name…

z:Dishwasher :Dishwasher x:

An instance of the class Dishwasher which is named z.

An anonymous instance of the class Dishwasher.

Unspecified classifier.

For the first two, Rhapsody looks for an existing classOR asks if you are creating a new one.

{Lifeline

Page 6: Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.

6

Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005

From Rhapsody’s Documentation

The recipient of a message is either a class or a reactive class. Reactive classes have statecharts, whereas nonreactive classes do not. Reactive classes can receive events, triggered operations, and primitive operations. Non-reactive classes can receive only messages that are calls to primitive operations. Events are usually shown with slanted arrows to imply that they are asynchronous (delivery takes time). Triggered operations are shown with straight arrows to imply that they are synchronous (happen immediately).

Page 7: Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.

7

Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005

A message represents an interaction between objects, or between an object and the environment. A message can be an event, a triggered operation, or a primitive operation. In the metamodel, a message defines a specific kind of communication. The communication could be raising a signal, invoking an operation, or creating or destroying an instance.

Messages

Page 8: Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.

8

Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005

Synchronous MessageThe UML standard uses a straight line with

a solid arrow at the end to represent a synchronous message.

The message is noted on the line along with the inputs to the message.

startSystem(mode = 1)

Page 9: Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.

9

Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005

Return Message

Return messages are represented by a dash line with an open arrow at the end. Return values can be expressed if needed.

status_result

Page 10: Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.

10

Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005

Example of Centralized Control

Ref: Martin Fowler – UML Distilled, 3rd Edition

ExecutionOccurence

Page 11: Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.

11

Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005

Example of Distributed Control

Ref: Martin Fowler – UML Distilled, 3rd Edition

Page 12: Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.

12

Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005

Creation and Deletion of Participants

Ref: Martin Fowler – UML Distilled, 3rd Edition

Page 13: Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.

13

Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005

Slanted Messages (Asynchronous)

In the UML standard, messages with an open arrowhead are asynchronous.

Rhapsody adds to the standard. A message drawn on a slant is interpreted as an event if the target is a reactive class, and as a primitive operation if the target is a nonreactive class. A slanted message emphasizes that time passes between the sending and receiving of the message. Slanted messages can cross each other.

Page 14: Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.

14

Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005

Page 15: Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.

15

Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005

Creating a Condition Mark

A condition mark (or state mark) is displayed on an instance line. A condition mark shows that the object has reached a certain condition or is in a certain state. Often, the name corresponds to a state name in the object's statechart.

                                           

Page 16: Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.

16

Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005

Creating a Timeout The notation for timeouts is similar to the notation for events sent by an object to itself. There are two differences:

•A timeout starts with a small box. •The name is a tm(x).

The label on a timeout arrow is a parameter specifying the length of the timeout. Timeouts are always messages-to-self.

Page 17: Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.

17

Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005

Creating a Canceled Timeout When designing a software system, you can

establish waiting states, during which your program waits for something to occur. If the event occurs, the timeout is canceled. The sequence diagram shows this with a canceled timeout symbol. If it does not happen, the timeout wakes up the instance and resumes with some sort of error recovery process. Canceled timeouts are always messages-to-self.

Page 18: Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.

18

Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005

Operator Meaning

alt Alternative multiple fragments; only the one whose condition is true will execute (Figure 4.4).

opt Optional; the fragment executes only if the supplied condition is true.

Equivalent to an alt with only one trace (Figure 4.4).

par Parallel; each fragment is run in parallel.

loop Loop; the fragment may execute multiple times, and the guard indicates the basis of iteration (Figure 4.4).

region Critical region; the fragment can have only one thread executing it at once.

neg Negative; the fragment shows an invalid interaction.

ref Reference; refers to an interaction defined on another diagram. The frame is drawn to cover the lifelines involved in the interaction. You can define parameters and a return value.

sd Sequence diagram; used to surround an entire sequence diagram, if you wish.

Common Operators for Interaction Frame

Ref: Martin Fowler – UML Distilled, 3rd Edition

Page 19: Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.

19

Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005

Interaction Frames

procedure dispatch foreach (lineitem) if (product.value > $10K) careful.dispatch else regular.dispatch end if end for if (needsConfirmation) messenger.confirm end procedure

Ref: Martin Fowler – UML Distilled, 3rd Edition

Page 20: Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.

20

Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005

Use of Reference

Referenced frame

Page 21: Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.

21

Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005

Reference Example Continued

Frame Name

Page 22: Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.

22

Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005

Parallel Operation Example

Page 23: Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.

23

Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005

Rhapsody’s Implementation

The Toolbar

Page 24: Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.

24

Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005

Page 25: Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.

25

Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005

Communication Diagrams

These emphasize the organizations of objects that participate in an interaction. Typically, it is vertically oriented, and unlike sequence diagrams they do not show the lifeline of an object nor do they show the focus of control.

Page 26: Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.

26

Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005http://www.agilemodeling.com/artifacts/communicationDiagram.htm

Example of Communication Diagram

Page 27: Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.

27

Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005

Which comes first – collaboration or class diagrams?

• Generally, make an initial pass on classes

• Collaboration diagrams may require you to re-evaluate your class design.

• It is a cyclic, iterative process of understanding.

Page 28: Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.

28

Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005

Final thought

● To model flows of control by timing order, the sequence diagram is more appropriate.

● Communication diagrams are best when modeling flows of control by organization.

Page 29: Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.

29

Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005

Page 30: Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.

30

Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005

Page 31: Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.

31

Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005

Page 32: Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.

32

Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005

Page 33: Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.

33

Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005