Ad Code

Difference between Composition, Aggregation and Association

What is the difference between Composition, Aggregation and Association?  Can we say composiiton and aggregation are one and same things?



Association describes the relationship between two objects and it describes how an object is associated with another object. Both Composition and Aggregation are forms of Association relationship. Aggregation is a specialize form of Association where one object becomes part of another object. In other words, we can say that Aggregation occurs when an object is composed of multiple objects. For example, a room can contain furniture of different types so there is an Aggregation relationship between room and furniture. Aggregation is a weak relationship between objects because in case of aggregation, the relating objects have their own life and each object can maintain its state independently.

Composition is again specialize form of Aggregation and we can call this as a “death” relationship. It is a strong type of Aggregation. In case of Composition relation, the relating objects cannot live independent of each other. For example, A class contains students. A student cannot exist without a class. There exists composition between class and students.
Reactions

Post a Comment

0 Comments