Re: aggregation and states



Date view Thread view Subject view Author view Attachment view

From: Ulf Schuenemann (ulf@cs.mun.ca)
Date: Tue 04 Jun 2002 - 01:50:52 BST


Les,

> So in my example of a car with wheels is an aggregation,
> because a wheel has a life outside of a car in most cases,

All that UML says about living is that destruction of the composite
object (its removal from the system) implies destruction of the
component objects.  By the same token, if that which is a car is
destroyed (removed from the world) then also the wheels are destroyed.
[I am not talking of the dismanteling of the car into its components.]
So the wheel, while it is a wheel of the car, has not much life
outside of the car.

Another thing is to remove a wheel from the car. Then a destruction of
the car would not affect the wheel any more (because it is no
component any more).  Again this is something which UML composition
explicitly allows: wheel objects can be dynamically removed from car
objects, and also they can be dynamically added to others (car
objects, airplane objects, ...).  Although UML remains unspecific
about the details, there seems to be no more involved in this than the
destruction/creation of composition links.

The existence with or without cars is not specified by composition
versus aggregation but by the same means as any other relationship
between objects can be limited: by multiplicity and changeability.

  Car <#>------- Wheel   Wheels exist only in a car (and are destroyed
         1               with it), but can be exchanged between cars

  Car <#>------- Wheel   Each wheel may be in a car or not, but this
       <<frozen>>        must be decided when it is created

As for the creation of parts, UML does not seem to say anything about
this [please correct me if I'm wrong].  But some authors have proposed
that creation of the composite object triggers creation of all its
(necessary) components. I can recall

  David Harel, Eran Gery: Executable Object Modeling with Statecharts;
  Computer 30(7) July 1997 (early version in ICSE'96)

  Conrad Bock, James Odell: A more complete model of relations and
  their implementations: aggregation; JOOP 11(5) Sep 1998.


Just my $.02

Ulf

Date view Thread view Subject view Author view Attachment view