Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College."— Presentation transcript:

1 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 2 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, 3 rd Edition

3 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 3 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, 3 rd Edition

4 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 4 ● Analyze and design scenarios between objects. ● Refine object definition and behavior. ● Executable representation ● Basis for test cases Key Benefits Summarize

5 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 5 What’s in a name… z:Dishwasher:Dishwasherx: 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 class OR asks if you are creating a new one. { Lifeline

6 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 6 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).

7 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 7 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

8 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 8 Synchronous Message The 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)

9 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 9 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

10 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 10 Example of Centralized Control Ref: Martin Fowler – UML Distilled, 3 rd Edition Execution Occurence

11 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 11 Example of Distributed Control Ref: Martin Fowler – UML Distilled, 3 rd Edition

12 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 12 Creation and Deletion of Participants Ref: Martin Fowler – UML Distilled, 3 rd Edition

13 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 13 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.

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

15 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 15 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.

16 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 16 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.

17 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 17 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.

18 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 18 OperatorMeaning 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, 3 rd Edition

19 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 19 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, 3 rd Edition

20 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 20 Use of Reference Referenced frame

21 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 21 Reference Example Continued Frame Name

22 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 22 Parallel Operation Example

23 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 23 Rhapsody’s Implementation The Toolbar

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

25 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 25 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.

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

27 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 27 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.

28 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 28 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.

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

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

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

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

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


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

Similar presentations


Ads by Google