UML Standard Diagrams
In the previous chapters we have discussed about the building blocks and other necessary elements of UML. Now we need to understand where to use those elements.
The elements are like components which can be associated in different ways to make a complete UML pictures which is known as diagram. So it is very important to understand the different diagrams to implement the knowledge in real life systems.
Any complex system is best understood by making some kind of diagrams or pictures. These diagrams have a better impact on our understanding. So if we look around then we will realize that the diagrams are not a new concept but it is used widely in different form in different industries.
We prepare UML diagrams to understand a system in better and simple way. A single diagram is not enough to cover all aspects of the system. So UML defines various kinds of diagrams to cover most of the aspects of a system.
You can also create your own set of diagrams to meet your requirements. Diagrams are generally made in an incremental and iterative way.
There are two broad caetgories of diagrams and then are again divided into sub-categories:
The structural diagrams represent the static aspect of the system. These static aspects represent those parts of a diagram which forms the main structure and therefore stable.
These static parts are represents by classes, interfaces, objects, components and nodes. The four structural diagrams are:
- Class diagram
- Object diagram
- Component diagram
- Deployment diagram
Class diagrams are the most common diagrams used in UML. Class diagram consists of classes, interfaces, associations and collaboration.
Class diagrams basically represent the object oriented view of a system which is static in nature.
Active class is used in a class diagram to represent the concurrency of the system.
Class diagram represents the object orientation of a system. So it is generally used for development purpose. This is the most widely used diagram at the time of system construction.
Object diagrams can be described as an instance of class diagram. So these diagrams are more close to real life scenarios where we implement a system.
Object diagrams are a set of objects and their relationships just like class diagrams and also represent the static view of the system.
The usage of object diagrams is similar to class diagrams but they are used to build prototype of a system from practical perspective.
Component diagrams represent a set of components and their relationships. These components consist of classes, interfaces or collaborations.
So Component diagrams represent the implementation view of a system.
During design phase software artifacts (classes, interfaces etc) of a system are arranged in different groups depending upon their relationship. Now these groups are known as components.
Finally, component diagrams are used to visualize the implementation.
Deployment diagrams are a set of nodes and their relationships. These nodes are physical entities where the components are deployed.
Deployment diagrams are used for visualizing deployment view of a system. This is generally used by the deployment team.
Note: If the above descriptions and usages are observed carefully then it is very clear that all the diagrams are having some relationship with one another. Component diagrams are dependent upon the classes, interfaces etc which are part of class/object diagram. Again the deployment diagram is dependent upon the components which are used to make a component diagrams.
Any system can have two aspects, static and dynamic. So a model is considered as complete when both the aspects are covered fully.
Behavioral diagrams basically capture the dynamic aspect of a system. Dynamic aspect can be further described as the changing/moving parts of a system.
UML has the following five types of behavioral diagrams:
- Use case diagram
- Sequence diagram
- Collaboration diagram
- Statechart diagram
- Activity diagram
Use case Diagram:
Use case diagrams are a set of use cases, actors and their relationships. They represent the use case view of a system.
A use case represents a particular functionality of a system.
So use case diagram is used to describe the relationships among the functionalities and their internal/external controllers. These controllers are known as actors.
A sequence diagram is an interaction diagram. From the name it is clear that the diagram deals with some sequences, which are the sequence of messages flowing from one object to another.
Interaction among the components of a system is very important from implementation and execution perspective.
So Sequence diagram is used to visualize the sequence of calls in a system to perform a specific functionality.
Collaboration diagram is another form of interaction diagram. It represents the structural organization of a system and the messages sent/received. Structural organization consists of objects and links.
The purpose of collaboration diagram is similar to sequence diagram. But the specific purpose of collaboration diagram is to visualize the organization of objects and their interaction.
Any real time system is expected to be reacted by some kind of internal/external events. These events are responsible for state change of the system.
Statechart diagram is used to represent the event driven state change of a system. It basically describes the state change of a class, interface etc.
State chart diagram is used to visualize the reaction of a system by internal/external factors.
Activity diagram describes the flow of control in a system. So it consists of activities and links. The flow can be sequential, concurrent or branched.
Activities are nothing but the functions of a system. Numbers of activity diagrams are prepared to capture the entire flow in a system.
Activity diagrams are used to visualize the flow of controls in a system. This is prepared to have an idea of how the system will work when executed.
Note: Dynamic nature of a system is very difficult to capture. So UML has provided features to capture the dynamics of a system from different angles. Sequence diagrams and collaboration diagrams are isomorphic so they can be converted from one another without losing any information. This is also true for statechart and activity diagram.