Download presentation
Presentation is loading. Please wait.
Published byTomas Helland Modified over 6 years ago
1
Interaction diagrams Interaction diagrams are models that describe how groups of objects collaborate in some behavior. Typically, an interaction diagram captures the behavior of a single use case. The diagram shows a number of objects and the messages that are passed between these objects within the use case. Interaction diagrams model the behavior of use cases by describing the way groups of objects interact to complete the task. An interaction diagram shows an interaction, consisting of a set of objects and their relationships, including the messages that may be dispatched among them. There are two kinds of interaction diagrams: sequence diagrams and collaboration diagrams.
2
Interaction diagrams contd…
An Interaction diagram shows you, step-by-step, one of the flows through a use case: what objects are needed for the flow, what messages the objects send to each other, what actor initiates the flow, and what order the messages are sent. We can draw additional diagrams showing what happens with the alternate flows, such as what happens when someone requests a frequent-flyer ticket, what happens when someone's credit card is denied, and so on. All of the different scenarios that our system will need to implement are documented in an Interaction diagram. Although a Sequence diagram and a Collaboration diagram show you the same information, there are a couple of differences between these two diagrams. Sequence diagrams can show a focus of control; Collaboration diagrams can show a data flow.
3
Sequence diagrams A sequence diagram is an interaction diagram that emphasizes the time ordering of messages A sequence diagram is an interaction diagram that describes how operations are carried out -- what messages are sent and when. Sequence diagrams are organized according to time. The time progresses as you go down the page. The objects involved in the operation are listed from left to right according to when they take part in the message sequence.
5
Sequence Diagrams Within a sequence diagram, an object is shown as a box at the top of a dashed vertical line
6
This vertical line is called the object's lifeline
This vertical line is called the object's lifeline. The lifeline represents the object's life during the interaction. Each message is represented by an arrow between the lifelines of two objects. The order in which these messages occur is shown top to bottom on the page. Each message is labeled at minimum with the message name; you can also include the arguments and some control information. You can show a self-call, a message that an object sends to itself, by sending the message arrow back to the same lifeline. First, there is a condition, which indicates when a message is sent (for example, [needsReorder]). The message is sent only if the condition is true. Conditions are useful in simple cases like this, but for more complicated cases, the second useful control marker is the iteration marker, which shows that a message is sent many times to multiple receiver objects, as would happen when you are iterating over a collection. You can show the basis of the iteration within brackets, such as *[for all order lines]. A return, indicates a return from a message, not a new message. Returns differ from the regular messages in that the line is dashed.
7
Collaboration diagrams
A collaboration diagram is an interaction diagram that emphasizes the structural organization of the objects that send and receive messages. Within a collaboration diagram, the example objects are shown as icons. As on a sequence diagram, arrows indicate the messages sent within the given use case. This time, however, the sequence is indicated by numbering the messages.
11
When to Use Interaction Diagrams
You should use interaction diagrams when you want to look at the behavior of several objects within a single use case. Interaction diagrams are good at showing collaborations among the objects; they are not so good at precise definition of the behavior. Typically, a sequence diagram captures the behavior of a single scenario. The diagram shows a number of example objects and the messages that are passed between these objects within the use case.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.