The main difference between Aggregation and Association is that aggregation is a type of association, which describes the “has-a” relationship between two objects, while the association is a relationship between two objects.
It is necessary to design software before implementing it. Unified Modelling Language (UML) is a visual diagramming language that helps to model a software. It gives a pictorial representation of the system. Therefore, even a non-technical person can easily understand and learn UML. Moreover, class and object diagrams are two types of UML diagrams. There are relationships between the classes and objects. These diagrams contain aggregations and associations. Overall, aggregation is a type of association. Finally, the programmer can convert these concepts into a program.
Key Areas Covered
Aggregation, Association, UML
What is Aggregation
Aggregation is a type of association. In other words, it is a special case of association. When an object “has-a” another object, we can consider it as an aggregation. Thus, aggregation explains the “has-a” relationship between objects. In UML, a diamond symbol represents and aggregation. The direction describes which object contains the other object.
For example, an employee is an object of type Employee class. It has a property called address. The address belongs to another class called Address. Therefore, the employee is linked to the address by a “has-a” relationship. Thus, it is an aggregation.
What is Association
Association is a relationship between two objects. It can define the multiplicity between objects. It denotes whether the objects have one to one, one to many, or many to many associations. For example, assume that there are two classes – A and B. If one object of A relates to one object of B, then it is one to one association. But, if one object of A relates to multiple objects of B, then that relationship is one to many. Similarly, if multiple objects of A are related to multiple objects of B, then the relationship is many to many. Therefore, these relationships define the association between objects.
For example, assume that there are two objects for customer and product. The customer buys products, and they have a simple relationship, which is an association. Furthermore, in UML, an arrow represents an association.
Difference Between Aggregation and Association
Aggregation is an association between two objects which describes the “has a” relationship, while the association is a relationship between two objects.
A diamond symbol represents an aggregation, while an arrow represents an association.
Aggregation is a type of association whereas association does not depend on aggregation.
Aggregation and association are two concepts in UML. After designing the system, the programmer can implement this concept using a programming language. The main difference between Aggregation and Association is that Aggregation is a type of association which describes the “has-a” relationship between two objects, while the association is a relationship between two objects. In brief, aggregation is a special case of association.
1. “Association, Aggregation, Composition, Abstraction, Generalization, Realization, Dependency.” Javapapers, Available here.