• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Aggregation vs Composition

 
Ahetuki Neti
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the difference between aggregation and composition?
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Composition is really a strong form of aggregation.
  • Composed objects have only one owner
  • Composed objects cannot exist independent of their owner (components live and die with their owner)
  • Aggregations may form "part of" the aggregate, but may not be essential to it. They also may also exist independent of the aggregate.


  • [ May 30, 2003: Message edited by: Lasse Koskela ]
     
    Ilja Preuss
    author
    Sheriff
    Posts: 14112
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    With other words: Composition adds a responsibility for controlling the lifetime of the part.
    In garbage collected languages like Java, there isn't much use for composition, in fact...
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic