aspose file tools*
The moose likes OO, Patterns, UML and Refactoring and the fly likes Aggregation vs Composition Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Aggregation vs Composition" Watch "Aggregation vs Composition" New topic
Author

Aggregation vs Composition

Ahetuki Neti
Greenhorn

Joined: May 29, 2003
Posts: 20
What is the difference between aggregation and composition?


Ahetuki, the Constant.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
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 ]

    Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
    Ilja Preuss
    author
    Sheriff

    Joined: Jul 11, 2001
    Posts: 14112
    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...


    The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Aggregation vs Composition