Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Aggregation and Composition query  RSS feed

 
RaviNada Kiran
Ranch Hand
Posts: 528
  • 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
Posts: 53749
127
  • 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
  • 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
Posts: 53749
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not a case of coding, but of design.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!