Sequence nd Collaboration diagrams, sometimes called collectively interaction diagrams, are two of several diagrams you can use to model the dynamic aspects of a system or subsystem. Both depict interactions consisting of a set of objects, their relationships, and messages exchanged among them.
Collaboration diagrams emphasize the structural organization of objects, while Sequence diagrams emphasize the time ordering of messages. Collaboration diagrams are essentially graphs; Sequence diagrams are essentially tables with different objects and messages depicted across the X axis and increasing time down the Y axis. However, the two diagram are semantically equivalent: one type can convert to the other type with no loss of information. Together enables you to do this conversion with a simple mouse click.
Though semantically equivalent, the two diagrams do not necessarily show the same information. For example, Collaboration diagrams explicitly show how objects are linked, while in Sequence diagrams the links are implied. Message return values show in Sequence diagrams but not in Collaboration diagrams.
If you need to learn how to create new diagrams in a project, or the techniques for placing elements and drawing links, consult the User's Guide topics found under " Working with Diagrams: Basic Diagram Techniques" in the Table of Contents. See Related Topics below.
A frequent use of the Sequence diagram is to model the dynamics of some Operation of a class. The system module Generate Sequence Diagram provides a simple, automated way to generate a Sequence diagram from an operation.
To generate a Sequence diagram from an operation:
Open the Class diagram containing the class whose operation you want
to model.
Locate the desired class and the desired Operation.
Right-click the Operation and choose Genrate Sequence Diagram from the speedmenu.
Together generates a new Sequence diagram in the same package as the source class, with the same name as the source operation, and opens it in the Diagram pane.
Note:This
feature only works in products that support Java,
in projects
where Java is the target programming language.
Collaboration and Sequence diagrams both typically contain:
Objects
Messages
Relationship Links
Together interaction diagrams also include Actors than can send and receive messages.
If you've not previously drawn Sequence diagrams using Together, a few pointers may be in order.
Objects display with a default lifeline when placed on the diagram. Their tops align vertically. If you draw a Message to an Object and then check the created property of the Message, the created Object will move downward to show that it exists at a point forward in time from its creator.
You can lengthen or shorten object lifelines as needed by dragging the horizontal line of the bottommost Message link upward or downward. You can arrange the position of other intervening Messages this way also.
You can reorder the Sequence diagram, maintaining any Message links already created between the Objects. Select any Object and drag it to the desired position. Such change is performed across the X axis of Objects- you cannot move Objects vertically along the Y axis except as described in the first point above.
The bold X indicating destruction of a created Object is rendered automatically: draw a Message to the Object and check the Message's destruction property.
The focus controls of Objects that show periods of time an object performs some action is also rendered automatically: just draw Message links to create them.
You can nest Messages by originating Message links from a focus control
Use properties of Message links for specifying such things as
When you draw a Message between Objects, a generic link line displays between the Objects and a list of Messages is created above it. The link line is present as long as there is a t least one Message between Objects.
As you add Messages, these display in time-ordered sequence from top-to-bottom of the messages list. You can select Messages and edit their properties in the message properties Inspector just as you can in a Sequence diagram.
The Collaboration diagram adds the capability of showing relationships between Objects. In addition to the default link, you can add links to show Association and Aggregation relationships. These links do not display if you view the diagram as a Sequence diagram.
A mentioned in the introduction above, Collaboration and Sequence diagrams are just different ways of viewing the same information. Together enables you to view either type of interaction diagram as the other type. However, when you create a new diagram, you must specify that it is either a Sequence diagram or a Collaboration diagram, and Together then tracks it as such. The diagram displays in the Explorer as the type of origin, and opens in that view. That is to say, if you create a Sequence diagram, it will always show in the Explorer, and open in the Diagram pane as a Sequence diagram. But you can view it as a Collaboration diagram.
To view an interaction diagram as the other type:
Right-click on the diagram background.
If the diagram is a Sequence diagram, choose View as Collaboration from the diagram speedmenu. If viewing a Collaboration diagram, the menu command is View as Sequence.
Repeat this process to switch back and forth.
Note: You can also do this switch from the speedmenus of interaction diagrams in the Explorer.
An object role in a Sequence diagram is shown as a vertical dashed line called the "lifeline". The lifeline represents the existence of the object at a particular time. If the object is created or destroyed during the period of time shown on the diagram, then its lifeline starts or stops at the appropriate point; otherwise it goes from the top to the bottom of the diagram. An object symbol is drawn at the head of the lifeline.
|
Property |
Description |
|
Name |
Every object has a name to distinguish it from other classes. Name is a text string. You need only enter the simple name for Objects. The qualified name is used when you specify the Object's classifier (see instantiates). |
|
Instantiates |
Specifies the Object's classifier. You can either enter the value yourself, or pick the class from a dialog that lists all the resources available to the project. When you apply this property, the Object displays its fully qualified name. The properties Inspector displays the Class tab in which you can access the properties of the Object's class. Tip: You can also specify the classifier by selecting the Object in the diagram or the Explorer and calling Choose Class from its speedmenu. |
A message is a communication between objects that conveys information with the expectation that action will ensue. The receipt of a message is a kind of event. A message is shown as a horizontal solid arrow from the lifeline of one object to the lifeline of another object. The message may also be drawn from and to the same object, representing a message from an object to itself. The arrow is labeled with the name of the message (operation or signal) and its argument values. The arrow may also be labeled with a sequence number to show the sequence of the message in the overall interaction. Sequence numbers are useful on the diagrams for identifying concurrent threads of control.
Properties of Messages, and the labels these create on the diagram convey a great deal of information about the dynamics of the interaction, especially in Sequence diagrams. You won't necessarily set a value for every property: for example you wouldn't set Condition unless modeling some elementary branching.
|
Property |
Description |
|
Label |
Optional arbitrary identifier. For example, if the message is one that creates another Object, you could label it "create". |
|
Number |
Time-ordered sequence number. Value is automatically incremented as you draw Message links. You could modify this value for two or more Messages to reorder their time sequence. |
|
Operation |
If the Message is sent by an operation, you can identify it here. Enter a value or pick the operation from an explorer dialog listing your project resources. You can specify arguments and/or return value, if any, in those properties. |
|
Condition |
Normally a Boolean expression (e.g., errorCode > 0). |
|
Iteration |
Enter a value if the Message is iterative or sent on a given iteration |
|
Creation |
Check if the Message is one that creates the Object to which it is sent |
|
Destruction |
Check if the Message is one that destroys the Object to which it is sent |
|
Synchronization |
Specify how or whether the target Object waits for some result. Useful when modeling multiple threads of flow control. |
The Actor enables you to create sequence diagrams that model how business workers interact with and handle business objects while performing the workflow of a realization of a business use-case.
The Actor in a Sequence diagram displays a lifeline and can exchange messages with other Actors and/or objects.
Creating a Message-to-self
To create a message from an Object back to itself:
Click on the Self Message button on the diagram's toolbar
Click on the Object's life line at the point where you want the Message to appear
Creating a Message link that calls an operation
For such message links there is additional tab "Operation" in the Inspector and, if the Editor pane is visible, the operation's source code is displayed there.
To create a Message link that calls an operation:
Create the Message link between two objects. Both objects must have their instantiates property set to point to a class.
Select the message link.
In the Inspector, go to the operation field and launch the picker dialog using the field's browse button to display the Choose Operation Name dialog. The dialog displays the operations of the receptor object's class.
Select the operation and click OK. This renames the Message link to the operation's name.
If you now select this Message link, the Inspector displays two tabs. The tabs are MessageLink (Message link properties) and Operation. The Operation tab displays the operation's properties.
Reordering Message links
Select and drag Message links up and down the Object lifeline to reorder them. Reordering automatically updates the Message link numbers.
Sometimes you may wish to reorder message links keeping their sequential order and freeing the space between for new links. To do this, select a Message link line, press CTRL, and drag it . This shifts all succeeding links. If you select a number of Message links (pressing Ctrl key), then those selected are moved keeping their increments.
You can find detailed information on UML modeling techniques for interaction diagrams in Chapters 18, and information about objects in Chapter 13 of the UML User's Guide.