Download presentation
Presentation is loading. Please wait.
1
Chapter 4 Sequence Diagrams
2
Introduction “Interaction diagrams describe how a group of objects collaborate in some behavior” - M. Fowler Objects communicate with each other by sending messages. Sending a message is another name for a member function call. Some C++ examples of member function calls ... objectName.messageName( ); objectPointer->messageName( ); (*objectPointer).messageName( ); An interaction is a set of messages exchanged among a set of objects in order to accomplish a specific goal.
3
Introduction Interaction diagrams ...
Are used to model the dynamic aspects of a system. Aid the developer visualize the system as it is running. Are storyboards of selected sequences of message traffic between objects. After class diagrams, interaction diagrams are possibly the most widely used diagrams in UML. Interaction diagrams commonly contain objects, links and messages.
4
Introduction Messages
A message is the vehicle by which communication between objects is achieved. A call is the most common type of message. The return of data as a result of a function call is also considered a message. A message may result in a change of state for the receiver of the message. The receipt of a message is considered an instance of an event.
5
Introduction Interactions model the dynamic aspects of a system by showing the message traffic between a group of objects. Showing the time-ordering of the message traffic is a central ingredient of interactions. Graphically, a message is represented as a directed line that is labeled. The sequence diagram is the most commonly used UML interaction diagram Typically a sequence diagram captures the behavior of a group of objects in a single scenario.
6
Sequence Diagrams Sequence diagrams are build around an X-Y axis.
Objects are aligned (in most cases) at the top of the diagram, parallel to the X axis. Messages travel (in most cases) parallel to the X axis. Time passes from top to bottom along the Y axis. Where a message arrow appears relative to the Y axis and other message arrows, determines the relative time the message is sent. Sequence diagrams most commonly show relative timings, not absolute timings. Links between objects are implied by the existence of a message.
7
Sequence Diagrams
8
Sequence Diagrams
9
Creating and Deleting Participants
10
Loops, Conditionals, and the Like
11
Loops, Conditionals, and the Like Using Pre 2.0 notations
12
CRC Cards
13
Links and Associations
Context Interactions appear whenever an object is linked to another object. Links A link is an instance of an association. Links must exist for interactions to occur. The multiplicity on both ends of a link is 1, since it is an instance of an association.
14
Links and Associations
15
Common Modeling Techniques
It is impossible to model all possible interactions within a system. Only model those interactions that are interesting or shed light on important aspects of the system. A system of even modest complexity may require several interaction diagrams. It does not matter whether you use interaction or collaboration diagrams to model interactions.
16
Modeling Control Flow by Time
Determine what scenarios need to be modeled. Identify the objects that play a role in the scenario. Lay the objects out in a sequence diagram left to right, with the most important objects to the left. Most important in this context means objects that are the principle initiators of events. Draw in the message arrows, top to bottom. Adorn the message as needed with detailed timing information.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.