views:

110

answers:

1

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

http://stackoverflow.com/questions/1384426/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

+5  A: 

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
Ahh! The GoF are wrong!
Diego
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