• Post Reply Bookmark Topic Watch Topic
  • New Topic

Aggregation and Composition  RSS feed

 
sajid dayer
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can any one explane the aggregation and composition with the low level example that i can understand easely
example should be programming example
 
Knute Snortum
Sheriff
Posts: 4288
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Composition means that the object doesn't make sense without the composed part. Aggregation means the aggregated part can exist independently from the object. So a car doesn't make much sense without an axle and vice versa. So a car is composed of an axle. But the CD player in the car can exists independently from the car (in some cases). So the car and the CD player are aggregated.
 
sajid dayer
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you give me simple program example ?
 
Knute Snortum
Sheriff
Posts: 4288
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a program, you usually delete composed object when you delete the composing object but an aggregated object can live on. A better example with my car analogy would be a VIN number and the CD player. I guess you can reuse axles (?) but you never reuse the VIN number.

With this knowledge, maybe you could take a stab at writing some code and post it here.
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Car and wheel.
Car and passenger.
 
Knute Snortum
Sheriff
Posts: 4288
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, Campbell, that's a much better example.
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!