Re: Aggregation vs composition
From: Daniel T. (postmaster_at_eathlink.net)
Date: 04/24/04
- Next message: Robert C. Martin: "Re: Rule against Circular Dependencies?"
- Previous message: Robert C. Martin: "Re: Aggregation vs composition"
- In reply to: Michael Rauscher: "Re: Aggregation vs composition"
- Next in thread: Michael Rauscher: "Re: Aggregation vs composition"
- Reply: Michael Rauscher: "Re: Aggregation vs composition"
- Reply: Universe: "Re: Aggregation vs composition"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 24 Apr 2004 13:02:06 GMT
Michael Rauscher <michlmann@gmx.de> wrote:
> Daniel T. schrieb:
> > Michael Rauscher <michlmann@gmx.de> wrote:
> >
> >>2. an element that is part of a composition may be included in an
> >>association/aggregation at the same time (in that case there are more
> >>than 1 possible references to the element).
> >
> >
> > Nonsense, if more than one object has a reference to our "part" then no
> > one object "has sole responsibility for the disposition" of that part.
>
> I think, you define a relation to be a composition only if the composite
> hides its parts and acts like a facade for them.
Yes, we must be able to use the "whole" without knowledge of the parts.
The point of composition is that the parts can be ignored
> Consider e.g.
>
> [Organization]<#>------>[OrganizationalUnit]<--------->[Employee]
As long as an employee has a reference to an OrganizationalUnit, the
Organization that the unit belongs to *cannot* destroy the unit. Thus
the Organization does not have control of the disposition of its parts,
thus no Composition relationship exists.
Your example is exactly why the Aggregation relationship exists;
conceptually we want to say that an OrganizationalUnit is part of an
Organization, however the relationship doesn't exhibit the properties of
a true composition relationship.
> In addition, the relation between classes/objects does not depend on the
> concepts, strength or weaknesses of a specific programming language
> (regarding Java one can only set references to null and hope, that the
> garbage collector will destroy the object (and call finalize) as soon as
> possible).
Of course not, pick any other language and the same principle holds
true. In order for object A to have "control of the disposition" of
object B, A must be the only object that has a reference to B. Having
control of the disposition means that A can destroy B at any moment in
time, if this is not true then no composition relationship exists.
- Next message: Robert C. Martin: "Re: Rule against Circular Dependencies?"
- Previous message: Robert C. Martin: "Re: Aggregation vs composition"
- In reply to: Michael Rauscher: "Re: Aggregation vs composition"
- Next in thread: Michael Rauscher: "Re: Aggregation vs composition"
- Reply: Michael Rauscher: "Re: Aggregation vs composition"
- Reply: Universe: "Re: Aggregation vs composition"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|