*
The moose likes Java in General and the fly likes Aggregation and Composition query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Aggregation and Composition query" Watch "Aggregation and Composition query" New topic
Author

Aggregation and Composition query

RaviNada Kiran
Ranch Hand

Joined: Jan 30, 2009
Posts: 528
Please help me understand this


Aggregation: Life times of the objects are not the same, one object can live even after the other object has been destroyed.
Composition: life time of objects got to be the same.

But i seem to get all these things in theory, but when it comes to coding am not able to translate these theories. To be particular i would want someone to help with me how these relationship can be coded


Waiting for your responses.


If you want something you never had do something which you had never done
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37945
    
  22
Somebody has told you nonsense. Aggregation and Composition have nothing to do with the lifetimes of the objects, but how closely they fit together.

Aggregation: Car----Driver.

A Car remains a car when it hasn't got a driver.

Composition: Car----Wheel.

A Car isn't a complete car if you take the wheels away.
RaviNada Kiran
Ranch Hand

Joined: Jan 30, 2009
Posts: 528
Theoretically fine.

Can you provide me any example on to java code.
How can a java program suit for this ? please provide me an example
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37945
    
  22
It's not a case of coding, but of design.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Aggregation and Composition query
 
Similar Threads
composite pattern and composition vs aggregation confusion
Java Coding and UML Aggregation v/s Composition
Example of Reflexive composition relation.
Association, Aggregation and composition implementation in java
Composition and Aggregation