The Unified Modeling Language (UML) is a modelling language that can be used for various applications. The primary goal of UML is to establish a standard for visualising the design of a system. It looks a lot like plans used in other engineering professions.
UML is a visual language, not a programming one. The behaviour and structure of a system are depicted using UML diagrams. UML aids modelling, design, and analysis for software engineers, businesspeople, and system architects. In 1997, the Object Management Group (OMG) decided to make Unified Modelling Language a standard. Since then, OMG has taken care of it. UML was certified as a default standard by the International Organization for Standardization in 2005. UML has been updated over time and is now being examined.
In this article, we will learn a UML component that is an object diagram.
Because object diagrams are formed from class diagrams, they rely on them.
An object diagram represents a class diagram. Class and object diagrams have identical fundamental notions. Object diagrams also depict a system's static perspective, but this view is a snapshot of the system at a specific point in time.
Object diagrams are used to represent a collection of things and their relationships.
Purpose of Object Diagrams
A diagram's purpose must be well understood before being used in practice. Object diagrams serve the same goals as class diagrams.
On the other hand, a class diagram illustrates an abstract model made up of classes and their relationships. On the other hand, an object diagram shows an actual instance at a specific time.
It indicates that the object diagram is more accurate than the actual system behaviour. The goal is to capture a system's static view at a specific point in time.
The object diagram's purpose can be summarised as follows:
Forward and reverse engineering.
Object relationships of a system
A static view of interaction.
Understand object behaviour and their relationship from a practical perspective
Notations Used in Object Diagram
Objects or Instance specifications
The object we produce when we instantiate a classifier in a system represents an entity that already exists in the system. Multiple instance specifications can be used to indicate changes in an object across time. In an Object Diagram, an object is represented by a rectangle. In an object diagram, one object is usually related to other objects.
Links
A link is a symbol that represents a connection between two objects.
For each end of the link, we represent the number of participants. A relationship between two classifiers is referred to as an association. A relationship between two instance specifications or objects is defined by the term link. A solid line is used to depict a connection between two items.
Notation
Meaning
1
One only
0..1
Zero or one
*
Zero or more
0..*
Zero or more
5
Five only
1..*
One or more
3..5
Three to Five
0..2
Zero or two
Dependency Relationships
A dependence relationship is used to illustrate when one element is dependent on another.
Dependency connections are used in class diagrams, component diagrams, deployment diagrams, and object diagrams. The relationship between dependent and independent components in a system is represented by dependence. Any change in one element's definition or structure may result in modifications in the other. A unidirectional relationship exists between two items.
Keywords (sometimes enclosed in angular brackets) are used to specify different sorts of dependency connections.
The types of dependency relationships utilised in UML are abstraction, binding, realisation, substitution, and usage.
Association
A reference relationship between two objects is called an association (or classes).
An association occurs when one object makes use of another. When one item refers to members of another object, we utilise association. The association might be one-way or bi-directional. The association is represented by an arrow.
Aggregation
A "has a" relationship is represented by aggregation.
A special type of association is aggregation. Aggregation is more specific than an ordinary association because it is based on a connection. It is a representation of a part-whole or part-of relationship. It's similar to a parent-child connection, except it's not inherited. When the lifecycle of enclosed items is not substantially dependent on the lifecycle of container objects, aggregation occurs.
Composition
Composition is a sort of relationship in which one child cannot exist without the other.
Composition is a sort of relationship that is distinct from others. It's akin to a parent-child connection, but it's not the same as an inheritance.
Drawing an Object Diagram
An object diagram is a type of class diagram, as we've just described. It suggests that an object diagram is made up of examples of the items in a class diagram.
As a result, both diagrams are made up of the same basic pieces, but they are represented in different ways. The elements in the class diagram are abstract to represent the blueprint, whereas the elements in the object diagram are concrete to represent the real-world object.
The number of class diagrams available to capture a specific system is restricted. If we consider object diagrams, however, we can have an infinite number of instances, each of which is unique. Only those events that have an influence on the system are taken into account.
From the above discussion, it is evident that a single object diagram cannot capture all of the required instances, or to put it another way, a single object diagram cannot specify all of a system's objects.
As a result, the answer is to examine the system and determine which instances contain critical data and associations. Second, we should solely think about the scenarios that will cover the functionality. Third, because the number of instances is limitless, we are required to do some optimisation.
Before drawing an object diagram, keep the following points in mind and make sure you understand them completely:
Object diagrams are made up of various objects.
The object diagram's link is used to connect things.
An object diagram is made up of two elements: objects and linkages.
Following that, make the following decisions before beginning to design the diagram:
The objective of the object diagram should be indicated by a meaningful name.
It's time to figure out what is most essential.
The relationship between things should be clarified.
To include in the object diagram, the values of various elements must be captured.
At times where further clarity is required, provide proper notes.
Example of Object Diagram
An object diagram is depicted in the diagram below. It reflects the Order management system explained in the Class Diagram chapter. The diagram below depicts the system at a specific point in time when it was purchased. It contains the following items.
Customer
Order
SpecialOrder
NormalOrder
Three order objects are now connected with the customer object (C) (O1, O2, and O3). These order items are linked to both special and regular order objects (S1, S2, and N1).
For the time period in question, the customer has three orders with varying numbers (15, 30, and 45).
In the future, the customer may increase the number of orders, and the object diagram will reflect this. If you look at the order, special order, and normal order objects, you'll notice that they all have values.
The values for orders are 15, 30, and 45, indicating that the objects have these values during a specific time (here, the time when the purchase is made is considered the instant) when the instance is captured.
The same may be said for special order and normal order objects with orders of 30, 60, and 90. If a different time of purchase is taken into account, these figures will alter.
The following object diagram was created with all of the points in mind, as mentioned above.
Applications of Object Diagrams
Object diagrams can be thought of as snapshots of a running system taken at a specific point in time. Consider the case of a train in motion.
If you take a picture of the moving train, you will get a static image that looks like this:
A state that is now active.
A specific number of passengers is required. If the photo is shot at a different time, the result will be different.
We can envision the snap of the running train as an object with the values listed above. This is true for any real-life system, no matter how basic or complex it is.
Object diagrams are used for the following purposes in a nutshell:
Creating a system's prototype.
Reverse engineering
Creating models for complex data structures.
From a practical standpoint, we should be able to comprehend the system.
FAQs
1. What is UML? The Unified Modeling Language (UML) is a modelling language that can be used for any purpose. The primary goal of UML is to establish a standard for visualising the design of a system.
2. What is Object Diagram? A class diagram is represented by an object diagram. Class and object diagrams have identical fundamental notions. Object diagrams also depict a system's static perspective, but this view is a snapshot of the system at a specific point in time.
3. What is Class Diagram? A static diagram is a class diagram. It depicts an application's static view. The class diagram is used not only for visualising, describing, and documenting many components of a system but also for creating software programme executable code.
4. Differentiate between Object and Class diagrams.
Serial No.
Class Diagram
Object Diagram
1.
It depicts a system's static view.
It depicts a system's real-time behaviour.
2.
The class diagram does not contain dynamic changes.
The object diagram captures dynamic changes.
3.
The data values and attributes of an instance are not involved here..
It incorporates data values and attributes of an entity.
4.
The object behaviour is manipulated in the class diagram.
Objects are the instances of a class.
5. What are the applications of the object diagrams?
The application areas where object diagrams can be employed are as follows.
To create a system prototype.
To create a model of a complex data structure.
To gain a practical understanding of the system.
Reverse engineering
Key Takeaways
In this article, we learned about the Object Diagrams in UML. We also learned about the purpose of the object diagrams. We learned how to implement object diagrams. We learned about the key differences between object and class diagrams.
For more information about Object-Oriented Software Design, here.