Aggregation is a particular type of Association, not a standalone concept. The terms are used for setting up a relationship between the objects and classes. The aggregation and association can be distinguished by the fact that if the relationship between the two objects is part-whole type, it is an aggregation. In contrast, if the linked objects can be considered as independent, then this is known as an association.
These concepts are very useful in class modelling, where an intuitive graphic representation of the system plays a major role while communicating with the customers.
Content: Aggregation Vs Association
|Basis for comparison||Association||Aggregation|
|Basic||Involves the relationship between two or more classifiers.||Specifies a whole and part relationship.|
|Syntax||Single line segment between the components.||Hollow diamond next to the assembly class.|
Definition of Aggregation
A simple association between two classes describes a structural relationship between them. Further, it signifies that both classes are associated with each other at the same level and holds equal importance. But what to imply, for a more refined relationship between those classes, where we could be able to distinguish between the classes having more priority than the classes having less priority. These types of relationships are known as aggregation.
An aggregation relationship is represented by a “has a” relationship, which means an object of a whole ‘has’ objects of the part. It supplements semantic connotations in a simple association. To show aggregation in UML we use an unfilled diamond at the whole (entity) end.
The simple form of aggregation is completely conceptual in sense. The meaning of the navigation does not change here, and the navigation specifies the direction as it does in the association. To merely distinguish the whole from the part, the open diamond is used.
Types of Aggregation
- Fixed Aggregation: The certain numbers and types of components are predefined. For example, a bike has one engine, two wheels and one handlebar.
- Variable Aggregation: The number of levels of aggregation are cannot be changed, but the number of parts may differ. For example, a train could be included in the variable aggregation.
- Recursive Aggregation: The object holds components of its own type. For example, in C++, an object is capable of containing the pointer of its own type and permits it to send messages
to other objects for the same class.
- Transitivity: If X is part of Y and Y is part of Z, then X is a part of Z.
- Antisymmetry: If X is a part of Y, Y is not a part of X.
- Propagation: The environment of the part is similar to the assembly.
Definition of Association
Association can be defined as a structural relationship that describes the connection of objects from one to the other entity. Let’s assume an association connects two classes which would help in relating the objects of one class to the other class. It is an analysis activity which shows semantic dependency, cardinality and navigability.
An association can be represented by a solid line segment between the classes. A small open arrowhead can also be used when the requester and collaborator are present, the arrowhead points towards the collaborator. If a class is having both ends of an association connecting to that particular class, then it means one object of that class is related to the other object of that class only. It is bidirectional in nature, which means it can go both ways at the same time and both classes can request to each other. Although, the term used to define the direction of the association is the navigability.
Type of association
- Binary association – If an association is connecting at most two classes, then it is said to be a binary association.
- N-ary association – When multiple classes are being connected through association, it is known as an n-ary association.
However, the relationship between the classes can be one-to-one, one-to-many and many-to-many.
Semantics of association
- Missing association: Append any missing association that is found.
- Misnamed association: A name determines an object within some context.
- Qualified association: A qualifier differentiates objects on the “many” side of an association (in case of one-to-many and many-to-many relationship).
- Role names: The role name specifies the role that a class in the association plays from the other classes point of view.
- Multiplicity: It frequently changes, so it should not be emphasized much.
Key Differences Between Aggregation and Association
- Association is both analysis and design activity in which dependencies between the classes at the same level of abstraction is presented while aggregation is a strong form of aggregation.
- Association is nothing but a reference from one object to another that enables access paths among objects in a system. Conversely, in aggregation, the reference from one object to another is more refined and has changed into composite object and component object. The component object is a part of the composite object.
- The aggregations can be easily recognized, which provides more flexibility over inheritance, whereas the association between objects does not give much flexibility.
The terms like association, aggregation, composition are mainly used in the UML designing where the aggregation and composition are the types of the association and differ mainly in fundamental semantic strength.