Re: Aggregation vs composition

From: Robert C. Martin (unclebob_at_objectmentor.com)
Date: 04/24/04


Date: Sat, 24 Apr 2004 07:59:08 -0500

On Sat, 24 Apr 2004 03:10:38 GMT, "Daniel T."
<postmaster@eathlink.net> wrote:

>
>The lifetime issue is a side effect. If only one object has a reference
>of our B object, then obviously it has responsibility for the
>disposition of said B object.

Composition does not imply that other objects cannot hold references
to the component. The rule is that only one composite can have
responsibility for the component at any given time.

-----
Robert C. Martin (Uncle Bob)
Object Mentor Inc.
unclebob @ objectmentor . com
800-338-6716

"Distinguishing between the author
and the writing is the essence of civilized debate."
           -- Daniel Parker



Relevant Pages

  • Re: Aggregation vs composition
    ... > the lifetime of the B objects they share. ... > then they also share responsibility for the disposition of that third ... Nevertheless, holding a reference does not mean *controlling* lifetime, it ... > Yes, A, if it knows all of the clients of a particular B object, could ...
    (comp.object)
  • Re: Aggregation vs composition
    ... Is this not Composition, ... responsibility for them, like in your example. ... Just because there's a method that returns a reference doesn't imply ... that this reference is used to destroy the referenced object. ...
    (comp.object)
  • Re: Aggregation vs composition
    ... >> the lifetime of the B objects they share. ... >> then they also share responsibility for the disposition of that third ... reference to B's": ... >> explicitly destroy a B object at any moment, the other clients of that B ...
    (comp.object)
  • Re: Aggregation vs composition
    ... > composition was defined to be a relationship where the part is destroyed ... > situation now defined by aggregation: the whole shares the responsibility ... See my "car" example below... ... where holding a reference does not have any influence on ...
    (comp.object)
  • Re: Aggregation vs composition
    ... >> have lifetime responsibility for its parts? ... A is responsible for controlling the lifetime, ... Yes, A, if it knows all of the clients of a particular B object, could ... request that all those clients drop their reference, ...
    (comp.object)