Collaboration diagrams like the sequence diagrams, shows how objects interact. It shows the objects along with the messages that travel from one to another. But, if sequence diagram does that, why UML need another diagram? Don't they do the same thing?
The
sequence diagram and the collaboration diagram are similar. They're semantically
equivalent, that is, the present the same information, and you can turn a sequence to a
collaboration diagram and vice versa. The main distinction between them is that the
sequence diagram is arranged according to time, the collaboration diagram according to
space.
A collaboration diagram is an extension of object diagram. In addition to the associations among objects, collaboration diagram shows the messages the objects send each other.
Messages
among objects are represented with arrows that points to receiving object, near the
association line between two objects. A label near the arrow shows what the message is.
The message typically tells the receiving object to execute one of its operations. A
pair of parentheses ends the message. Inside the parentheses, you put the parameters the
opearation works on.
Collaboration diagrams can be turned into sequence diagrams and vice versa. Thus, you have to be able to represent sequence information in a collaboration diagram. To do this you must know that:
Add a number to the label of a message, with the number
corresponding to the message's order in the sequence. A colon separates the number from
the message.
This is the basis of collaboration diagrams. In addition next two lessons will describe the process of writing collaboration diagrams.