What is the relationship between the terms "association", "aggregation", and "composition"?

I try to brush up on my technical interview skills as I plan to seek a better offer I don't recall being ever asked that really, but I still want to clear up any confusion. What is association, aggregation, and composition? As I understand Composition is a type of aggregation, aggregation is a type of composition With aggregation, the contained object may outlive the containing one; with composition, the lifecycles of the container and the contained object match (once the container dies, the contained object dies too) What I don't understand Does association itself imply a has-a relationship? Are there other types of association besides aggregation? Are there other types aggregation besides composition? E.g. is there a word for that "looser" aggregation that is not composition? This question is similar, but it doesn't really answer my questions

May 19, 2025 - 23:40
 0

I try to brush up on my technical interview skills as I plan to seek a better offer

I don't recall being ever asked that really, but I still want to clear up any confusion. What is association, aggregation, and composition? As I understand

  • Composition is a type of aggregation, aggregation is a type of composition
  • With aggregation, the contained object may outlive the containing one; with composition, the lifecycles of the container and the contained object match (once the container dies, the contained object dies too)

What I don't understand

  • Does association itself imply a has-a relationship?
  • Are there other types of association besides aggregation?
  • Are there other types aggregation besides composition? E.g. is there a word for that "looser" aggregation that is not composition?

This question is similar, but it doesn't really answer my questions