Question

I have been reading a couple of articles on stack overflow about aggreation and how it compares to delegation and composition. Mainly:

distinguishing between delegation, composition and aggregation (java OO design)

According to this and other articles I have read on here, the concession is that aggregation is that one object owns another, however, the death of one does not mean the death of the other. However, according to Design Patterns by the GoF:

"Aggregation implies that an aggregate object and its owner have identical lifetimes" [page 22 on the bottom]

Any advice on this?

Thanks

Was it helpful?

Solution

I've seen both kinds of definitions, but the established ones seem to be:

  • composition implies shared lifetime
  • aggregation implies no shared lifetime

IIRC, that's the meaning used in UML.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top