0% found this document useful (0 votes)
41 views

Unit 2

Collaboration diagrams allow you to see both the dynamic aspects and static relationships of business objects in a single diagram. They help document and describe the interactions between business objects as they call on each other's services to accomplish tasks. Collaboration diagrams focus on the relationships between objects, while sequence diagrams show the specific order and flow of messages.

Uploaded by

Khushi Pachauri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

Unit 2

Collaboration diagrams allow you to see both the dynamic aspects and static relationships of business objects in a single diagram. They help document and describe the interactions between business objects as they call on each other's services to accomplish tasks. Collaboration diagrams focus on the relationships between objects, while sequence diagrams show the specific order and flow of messages.

Uploaded by

Khushi Pachauri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

Unit 2

Collaboration Diagrams

• At the very heart of any complex software application are BUSINESS


OBJECTS.

• As the user interacts with the SOFTWARE, BUSINESS OBJECTS respond by


carrying out requested actions such as performing calculations, retrieving,
validating and manipulating data.

• 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.

• Collectively, both of these are known as INTERACTION diagrams.

• Collaboration Diagrams are also called as the COMMUNICATION Diagrams


Elements of a Collaboration Diagram

#1 Actors

• In reality, an actor is what invokes the interactions.

• For this reason, it is usually a starting point for the diagram.

• 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

• Represents each object of the system.

• It is noted with the format “Object name: Class name”.

• 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

• You can’t have a clear view of the sequence of messages in the


collaboration diagram in UML.
• The simplicity of the collaboration diagram in UML means that you don’t
have many available notation options to use to indicate more complex
relationships.
• In a collaboration diagram, the objects get changed and destroyed after
the message is conveyed, which might be difficult to track.
SEQUENCE DIAGRAM

• Depicts interaction between objects in a sequential order i.e. the order in


which these interactions take place.

• Also can be called event diagrams or event scenarios.

• Describe how and in what order the objects in a system function.

• Widely used by businessmen and software developers to document and


understand requirements for new and existing systems.
Sequence Diagram Notations
# Actors
• An actor represents a type of role where it interacts with the system
and its objects.
• An actor is always outside the scope of the system we aim to model
using the UML diagram.
Example : An actor interacting with seat reservation system
#Lifelines
• A lifeline is a named instance which depicts an individual participant in a
sequence diagram.
• Each instance in a sequence diagram is represented by a lifeline.
• Lifeline elements are located at the top in a sequence diagram.
• The standard in UML for naming a lifeline follows the following format
Instance Name : Class Name
We display a lifeline in a rectangle called HEAD with
its name and type.
The head is located on top of a vertical dashed line
(referred to as the stem) as shown.
ACTOR VS LIFELINE

Lifeline always portrays an object internal to the system


whereas
Actors are used to depict objects external to the system
# Messages
• Communication between objects is depicted using messages.
• The messages appear in a sequential order on the lifeline.
• Represented using arrows.
• Lifelines and messages form the core of a sequence diagram.
Messages can be broadly classified into the following categories :
• Synchronous Messages
• Asynchronous Messages
• Create Message
• Delete Message
• Reply Message
• Self Message
• Found Message
• Lost Message
Example of messages

--------------------------------------------
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

• An asynchronous message does not


wait for a reply from the receiver.
• The interaction moves forward
irrespective of the receiver processing
the previous message or not.
• We use a lined arrow head to
represent an asynchronous message.
Create message
Used to instantiate a new object in the
sequence diagram.
There are situations when a particular
message call requires the creation of an
object.
It is represented with a dotted arrow and
create word labelled on it to specify that it
is the create Message symbol.
Example – The creation of a new order on a
e-commerce website would require a new
object of Order class to be created.
Delete Message

• USED to delete an object.


• When an object is deallocated memory or
is destroyed within the system we use the
Delete Message symbol.
• It destroys the occurrence of the object in
the system.
• It is represented by an arrow terminating
with a x.
Example – In the scenario when the order
is received by the user, the object of order
class can be destroyed.
Self Message
• Certain scenarios might arise where the
object needs to send a message to itself.
• Such messages are called Self Messages
and are represented with a U shaped
arrow.
Example
Consider a scenario where the device wants
to access its webcam.
Such a scenario is represented using a self
message.
Reply Message
• Reply messages are used to show the
message being sent from the receiver to the
sender.
• Represented using an open arrowhead with a
dotted line.
• The interaction moves forward only when a
reply message is sent by the receiver.

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

• Found message is used to represent a


scenario where an unknown source sends
the message.
• It is represented using an arrow directed
towards a lifeline from an end point.
• For example:
Consider the scenario of a hardware failure.
Lost Message
• Lost message is used to represent a
scenario where the recipient is not
known to the system.
• It is represented using an arrow
directed towards an end point from a
lifeline.
• For example:
Consider a scenario where a warning is
generated.
# Guards
• To model conditions we use guards in UML.
• They are used when we need to restrict the
flow of messages on the pretext of a condition
being met.
• Guards play an important role in letting
software developers know the constraints
attached to a system or a particular process.
• EXAMPLE
In order to be able to withdraw cash,
having a balance greater than zero is a
condition that must be met as shown
below.
Example SEQUENCE DIAGRAM
1. Firstly the application is opened by the user.
2. The device then gets access to the web cam.
3. The webcam captures the image of the user.
4. The device uses algorithms to detect the face
and predict the mood.
5. It then requests database for dictionary of
possible moods.
6. The mood is retrieved from the database.
7. The mood is displayed to the user.
8. The music is requested from the database.
9. The playlist is generated
10. Finally shown to the user.
Differences between Collaboration and Sequence Diagrams

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.

You might also like