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
 
Back
Top