Wednesday, March 5, 2008

Defining Collaboration Diagrams

Use a Collaboration Diagram to model the interactions between classes in the object model.  Collaboration diagrams are also known as Object Message diagrams.

Collaboration diagrams are a technique for defining external object behavior. They include the same information as Sequence Diagrams (or message trace diagrams) but are better able to show asynchronous message passing.  Collaboration diagrams show how objects collaborate by representing objects by icons and their message passing as labeled arrows.

Notation


In the example of the notation for a collaboration diagram, objects (actors in use cases) are represented by rectangle icons.  In the example, the objects are Object1, Object2, Object…, ObjectN-1 ..., and ObjectN.

Messages passed (called interactions or events in use cases) between objects are represented by labeled arrows that start with the sending object (actor) and end with the receiving object.  In the example, the sample messages passed between objects are labeled  1: message1, 2: message2, 3: message3, etc., where the numerical prefix to the message name indicates its order in the sequence.  For example, Object1 first sends Object2 the message message1, Object2 in turn sends ObjectN-1  the message message2, and so on.  Messages that objects send to themselves are indicated as loops (e.g., message message5).

Method

Derive the collaboration diagrams from the sequence diagrams;  or create the object message trace in the same way that a sequence diagram is created, but represent it with the collaboration diagram notation.  Use operation numbering to preserve the synchronous ordering of the sequence diagram from which it is derived. 

To derive a collaboration diagram from a sequence diagram:

  • Draw a box for each object in the sequence diagram.
  • If the sequence diagram shows a message between the objects, draw a line connecting the objects on the message diagram.
  • Label the line with the message name and a number identifying the sequence in which the message appears.

Use special notation (e.g., the Unified Method draws asynchronous messages with a half-arrowhead to show a one-way, synchronous control flow) to express asynchronous operations.

Example

The technique is illustrated by a simple example. 
 

No comments: