File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Aggregation and Composition query

 
RaviNada Kiran
Ranch Hand
Posts: 528
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47313
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 528
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 47313
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not a case of coding, but of design.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic