Unit 2
Unit 2
Collaboration Diagrams
• Collaboration diagrams allow you to see both the dynamic aspects and static
relationships of business objects in a single diagram.
• Often, business objects need to call on the services of other business
objects to accomplish a particular task.
• There are two diagrams in the Unified Modeling Language (UML) that
help to document and describe this interaction?
• SEQUENCE DIAGRAMS AND COLLABORATION DIAGRAMS.
#1 Actors
• There are cases where you will have more than one actors in the same diagram.
In this instance, you must make sure that you name each one and place them in
distinguishable places.
#2 Objects
• Rules that you need to follow to use objects in the collaboration diagram in
UML. These are:
• You need to include both the object and class name.
• You must name every object.
• You don’t have to include every class.
• More than one objects can consist of a class.
• You first need to create the object and then the class.
#3 Links
• This element works as a connection between the actors and the objects.
• The link creates the route that the message will use to move from one element to
the next. It is indicated by a solid line.
#4 Messages
• Depicts the communication between objects.
• It is indicated by an arrow and contains a sequence number.
• The rules for using the messages are the following:
• The message’s arrow must be directed toward the receiving object.
• The path toward the receiving objects should be clear.
Simple Collaboration Diagram
Example Collaboration Diagram for Phone Dialer
Person/
ACTOR
Advantages of the Collaboration Diagram
• The collaboration diagram places objects at the center. When you are using it,
you don’t have to worry about the flow of the message. Instead, you are
highlighting the relationships between objects.
• It gives the flexibility to add any objects you might need at any given time.
Compared to other diagram types, the collaboration diagram is simpler, and
for this reason, new elements can be included.
• These are very useful for visualizing the relationship between objects
collaborating to perform a particular task. This is difficult to determine from
a sequence diagram.
• Collaboration diagrams can also help you determine the accuracy of your
static model (i.e., class diagrams).
Some developers take the step of creating static models of their business
objects, but don't "prove" their models by creating associated dynamic models.
Once you put your classes into action (or interaction), you can often see flaws
in your static model that may not have been discovered otherwise.
Cons of Collaboration Diagrams
--------------------------------------------
Synchronous messages
A synchronous message waits for a reply before
the interaction can move forward.
The sender waits until the receiver has completed
the processing of the message.
The caller continues only when it knows that the
receiver has processed the previous message i.e.
it receives a reply message.
A large number of calls in object oriented
programming are synchronous.
Solid arrow head is used to represent a
synchronous message.
Asynchronous Messages
Example
Consider the scenario where the device
requests a photo from the user.
Here the message which shows the photo
being sent is a reply message.
Found Message
The collaboration diagram is often associated and confused with the sequence
diagram. However, the two diagrams have some basic differences that set them
apart. These differences are the following:
• The collaboration diagram in UML visualizes the relationships between objects
WHILE Sequence diagram is the sequence of messages that flow between
objects.
• Collaboration diagram in UML can describe the general organization of the
objects WHILE the sequence diagram describes a particular use case.