Aggregate and composite?

  • Thread starter Thread starter William Stacey
  • Start date Start date
W

William Stacey

Please help me understand the difference or sameness of aggregate and
composite associations. Simple example with description would be helpful.
tia
 
William... Can you first write down your definition of aggregate and
composite? Just accepting my answer is not going to help you learn
much.

Regards,
Jeff
Please help me understand the difference or sameness of aggregate
and composite associations. Simple example with description would be
helpful.<
 
This may help: Composite class, containment by ownership:

class Radio
{
...
}
class Vehicle
{
...
}
class Car : Vehicle
{
Radio r= new Radio();
}

In a composite class the lifetimes of the object and sub object are
intertwined.

vs containment by reference:

class Radio
{
...
}
class Vehicle
{
...
}
class Car : Vehicle
{
private Radio r;
public Car(Radio r) {
this.r= r;
}
}


Regards,
Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top