2

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.

2 Answers 2

3

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.

1
  • Sounds fair enough. How come these concepts are often explained or presented as if they are independent concepts i.e. if you ask what are the relationships among a class you get told that there's an association, aggregation, composition, and generalization but why aggregation and composition are never part of sub-categories of association relationship?
    – cpx
    Nov 7, 2014 at 14:41
0

Having an association from object A to object B means that object A knows about the existence of object B and that it can access the (public) interface of object B.

Aggregation and composition can be seen as increasingly stronger forms of "knowing about", because when you "have" a B or even manage that B's lifetime, there is no getting around that you know about that B.

On the other hand, the semantic differences between "knowing about" and "having" are big enough that aggregation and composition really deserve separate treatment in an introductory text.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.