Introduction to UML Interaction Diagram
When we hear about the word “interaction” one this which pops in our mind is that the diagram is something to do with connection between different elements of the system. This characteristic shows the dynamic behavior of a system. Now, in case of UML the interactions are shown by two diagrams, both of which we would study in-depth later, are known to be Sequence diagram and collaboration diagram. Although the purpose of both the diagrams are pretty much similar, but understanding the subtle difference superficially, sequence diagram is related to time sequence of messages and collaboration diagram is related to overall organizational structure of objects which are responsible for sending and receiving messages.
Components of UML Interaction Diagram
Before we understand deeper on UML interaction diagram let us do some quick checks on the terminologies that will essentially help in understanding UML interaction diagram.
The main components of UML diagram are lifelines, messages, operators, state invariant and constraints. In this section we will go through each of these components one by one and understand deep about each component to get a clear overall picture. We would take some analogous instance which is very prevalent in our society, so that it becomes easier for our readers to understand the concepts faster.
Starting off with lifeline, it denotes a single participant in an interaction. Lifeline can be thought about as a smallest building block of interaction diagram or may be the role that instance would play in the interaction. There are many attributes that are possible for lifeline. One of them is “Name”, with which the lifeline is referred to in an interaction. This attribute is optional for lifeline. The next attribute is “Type” which is a mandatory attribute, as it represents the name of the classifier of which this lifeline is a part of. The last attribute is the “Selector”, which is similar to a flag option, i.e. a Boolean condition, which is used for selecting a particular instance. Again, this attribute is optional. Lifeline is like individual “Person” in a society.
The next component is “Messages”, which denotes the specific type of communication between lifelines in an interaction. This is pretty much analogous to conversations “Person” would have with another. This component dictates how 2 lifelines would interact among each other. Message includes many activities within itself. There might be a call message for calling an operation (performed by “Operator” another component discussed later), a message for creating an instance, message for destroying an instance and lastly for sending a signal. There are again different types of messages which are used in an interaction diagram. Some of them are Synchronous message, Asynchronous message, Return message, Object creation and many such more. One more thing which needs to be understood is that when message is being executed that has the focus of control and when the interaction has progressed over time, the focus of control moves between the lifelines.
The next component is “State invariants and constraints”. This component is very similar to the condition in a society that the message received might result in change of state of the person, something like getting happy or angry or whatever the feeling the message carried. This component is also the “state” of the lifeline during its lifetime which might satisfy some constraint or perform operation or maybe idle.
The next and the last component is “Operator”. This component signifies the operation which is to be performed on the operand. For example, some operator might lead to branching in the flow, some may lead to break of the flow and so on. This is analogous to the decision taken by a person in a society which would eventually decide the course of action.
Types of UML Interaction Diagram
So, to understand more about UML interaction diagram, we would need to dive deeper into understanding different types of interaction diagram defined in UML. Interaction is denoted by a rectangle with a small pentagon and are of 3 types:
- Sequence Diagram: The intent of having this diagram is to depict interaction between objects in sequential order. Using this diagram one can visualize the sequence of message flow in the diagram. This is where the lifelines, represented as a vertical bar, take part during execution. In this diagram the dotted line represents message flow between two or more objects and extends till the end of the page.
- Collaboration Diagram: With the help of collaboration diagram, relationship and interactions are depicted between software objects. Collaboration diagram is intended to be used for knowing the architecture of an object in the system, unlike sequence diagram which depicts the flow of message. Sometimes this diagram is also referred as communication diagram. Since, it tries to depict only the architecture of an object, it is assumed that collaboration diagrams are semantically weak.
- Timing Diagram: The last type of diagram, Timing diagram, is used to depict the state of a lifeline at any instance of time in form of waveform or graph. Notations are not required in case of timing diagram.
How is UML Interaction Diagram Drawn?
For drawing an interaction diagram, we tend to follow a procedure, though it may differ from case to case on the applicability of below steps.
- Identify and Add Components: First we would need to identify which components are present in the system and needs to be diagrammatized.
- Shapes Import or Add: Once we know the components, we would need to start adding shapes in our diagram to represent the operator or state. Incase more shapes are required; we may import them as well.
- Use of Sequence Markup for Automation: Let’s say we have to repeat a part of a diagram more than once, it is better to have a sequence markup and use it repetitively instead of making the same diagram more than once.
- Adding of Text/Concepts in the Diagram: We need to make sure that message sends out right information and reviewing it is the most important thing.
- Idea Implementing, Publishing and Sharing: After the diagram is implemented, we can readily publish it and share them across for scaling and knowledge transfer.
Conclusion
With this article we are aware of capabilities interaction diagram possesses. Once there, it is a crucial instrument in understanding the flow of message and the structural organization. These diagrams are widely used in the industry like, modelling flow of control, reverse engineering, organization of structure of interactive elements and many more such genres. This diagram helps in capturing different aspect of interactions!
Recommended Article
This is a guide to UML Interaction Diagrams. Here we discuss the Introduction to UML Interaction Diagrams and its components along with different types explained in detail. You can also go through our other suggested articles to learn more –