Object-oriented – Is composition and aggregation really a type of association relationship

compositionobject-orientedrelationships

From Wikipedia:

There are four different types of association: bi-directional,
uni-directional, Aggregation (includes Composition aggregation) and
Reflexive.

From what I know:

  • Composition relationship is used for objects that have a has-a relationship to each other. E.g. A car has-an engine.

  • Whereas, aggregation is a weaker form of composition relationship in which the object doesn't take the ownership of another object. E.g. A university department has a teacher.

  • In association relationship, there's no concept of has a being used and the objects association is completely independent and thus, they don't belong to a certain class. E.g. you drive a car.

What does it mean that composition and aggregation are a type of association relationships? or do they stand on their own?

On some other resources I have read which state that: "Composition is a special form of association" and "Composition is a special case of association" and they are described in independent sections of their own and not in a "sub-section" of association down below it. Therefore, the confusion about how exactly it is type or sub-type of association relationship.

Best Answer

Yes they are, composition is usually called a "strong" association, because if you get rid of the main class the other class has no reason for existance. Aggregation is a sort of "light" association, in which the deletion of one of the related classes does not interfere in the existance of the other.