Key Difference – Sequence Diagram vs Collaboration Diagram
Before developing software, it is necessary to have a good understanding of what should be developed. Therefore, it is required to design the system. It can be done using Unified Modeling Language (UML). It is not a programming language such as Java, C#. It is used to get a visual representation of the system. With the introduction of Object Oriented Programming (OOP), most programs and software were developed. It is a paradigm that helps to model a software with objects. The OOP concepts such as inheritance, encapsulation can be represented using UML. It is easy and simple to understand. It can be used even by non-programmers. Generally, one diagram is not enough to understand the entire system. There are various types of UML diagrams each covering different aspects. The sequence diagram and collaboration diagram are two interaction diagrams. The key difference between sequence diagram and collaboration diagram is that the sequence diagram is used when the time sequence is more important while the collaboration diagram is used when the object organization is more important. This article discusses the difference between sequence diagram and a collaboration diagram.
CONTENTS
1. Overview and Key Difference
2. What is Sequence Diagram
3. What is Collaboration Diagram
4. Similarities Between Sequence Diagram and Collaboration Diagram
5. Side by Side Comparison – Sequence Diagram vs Collaboration Diagram in Tabular Form
6. Summary
What is Sequence Diagram?
The sequence diagrams are used to represent the interaction between objects over a specific period of time. The request messages are represented by dark arrows, and the return messages are denoted by the dashed arrows. The rectangle vertical boxes represent the activation time of each object.
According to the above diagram, the customer object, sends a message to the product object to see whether the product is available. The product object sends a message to the stock object to find whether the product is available in the stock. Depending on the product availability, the stock will reply the product, and the product will reply the customer. Then the customer object sends the pay money message to the payment object. Finally, the receipt message is sent to the customer. The requested product, pay money requests. They are denoted by dark arrows. The yes/no, receipt are return messages. They are denoted by dashed arrows. The customer object is active throughout this process. The product and stock objects are active at the beginning. The payment object is active at the end because it should be activated to complete the payment. Overall, the sequence diagram provided information on the interaction between objects within the specific time period.
What is Collaboration Diagram?
A collaboration diagram focuses on the interaction between objects. It displays the object organization. A number indicates the method call sequence. Each number represents the method it is called.
According to the above collaboration diagram, the objects are represented using rectangles. The messages are represented by an arrow and a sequence number. The first message is order product. The second message is get price and the third message is do payment. Likewise, each message is given a sequence number. So, the number indicates how the methods are called one after the other. The conditional statements are denoted by square brackets. The payment via master and visa are separate conditions. The payment by master and the payment by visa belong to payment. So, they are denoted by 3.1 and 3.2.
What are the Similarities Between Sequence and Collaboration Diagram?
- Both Sequence and Collaboration Diagram are interaction diagrams in UML.
- Both Sequence and Collaboration Diagram describe the behavioural aspects of the system.
What is the Difference Between Sequence and Collaboration Diagram?
Sequence vs Collaboration Diagram |
|
The sequence diagram is a UML representation to visualize the sequence of calls in a system to perform a specific functionality. | The collaboration diagram is a UML representation to visualize the organization of the objects and their interaction. |
Representation | |
The sequence diagram represents the sequence of messages flowing from one object to another. | The collaboration diagram represents the structural organization of the system and the messages sent and received. |
Usage | |
If the time sequence is important, the sequence diagram can be used. | If the object organization is important, then the collaboration diagram can be used. |
Summary – Sequence Diagram vs Collaboration Diagram
When developing software, it is not possible to start developing directly. It is required to understand the system. UML is used to get a pictorial understanding of the system. UML is easier than general purpose programming languages such as Java, C++ etc. There are various UML diagrams which cover different aspects. Two of them are sequence diagram and a collaboration diagram. The difference between sequence diagram and collaboration diagram is, the sequence diagram is used when the time sequence is more important while the collaboration diagram is used when the object organization is more important.
Reference:
1.dnfvideo. UML Sequence Digram, .NET Interview Preparation Videos, 16 Aug. 2010. Available here
2.“UML – Interaction Diagrams.”, Tutorials Point, 8 Jan. 2018. Available here
3.“UML – Standard Diagrams.”, Tutorials Point, 8 Jan. 2018. Available here
4.Collaboration Diagrams, CMS Support, 25 Aug. 2015. Available here
Leave a Reply