3

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

Community
  • 1
  • 1
Diego
  • 16,830
  • 8
  • 34
  • 46

1 Answers1

6

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.

Pavel Minaev
  • 99,783
  • 25
  • 219
  • 289
  • 3
    They can't be "right" or "wrong" because the terms changed their meaning with time. GoF book was originally published in 1994. UML was standardized in 1997. – Pavel Minaev Oct 02 '09 at 02:25