Re: Articles or Turorials on Aggregation??
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Wed, 11 Jan 2006 21:41:11 -0000
Alan Pretre <no@spam> wrote:
> "Jon Skeet [C# MVP]" <skeet@xxxxxxxxx> wrote in message
> news:MPG.1e2f6e57bc3a8cac98ccb3@xxxxxxxxxxxxxxxxxxxxxxx
> > If the "embedded" object is no longer accessible after the enclosing
> > instance is no longer accessible, then even if it hasn't actually been
> > garbage collected, it's been destroyed as far as anything else is
> > concerned. There's no longer any way to get at the data in it.
>
> I think it is a matter of ownership, simply. If the "enclosing" object, so
> to speak, owns the reference*, it is responsible for the lifetime of it. If
> not, it is simply using it and the lifetime of the referenced object is
> independent of the container. Would you agree?
>
> Ref.: GoF p.22
>
> *Note: Ownership can be transferred to another container, but there can only
> be at most 1 owner.
It depends exactly what is meant by ownership. Responsibility for
lifetime? Responsibility for data?
I guess the question I'd like to ask is what *useful* distinction can
be made between the two in C#. Is there some way of interpreting the
patterns so that in some cases we could describe the usage as
aggregation and in some we could call it composition? Or do we need to
invent a new term for when we expose immutable data?
Suppose instead of exposing an actual string, we exposed the length as
one property, and allowed indexing of the string. A client could easily
reconstruct the string - they would be functionally equivalent,
wouldn't they? Would one be composition and the other aggregation?
--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.
- Follow-Ups:
- Re: Articles or Turorials on Aggregation??
- From: Alan Pretre
- Re: Articles or Turorials on Aggregation??
- From: Alan Pretre
- Re: Articles or Turorials on Aggregation??
- References:
- Articles or Turorials on Aggregation??
- From: SenthilVel
- Re: Articles or Turorials on Aggregation??
- From: Kevin Spencer
- Re: Articles or Turorials on Aggregation??
- From: Ignacio Machin \( .NET/ C# MVP \)
- Re: Articles or Turorials on Aggregation??
- From: Jon Skeet [C# MVP]
- Re: Articles or Turorials on Aggregation??
- From: Alan Pretre
- Articles or Turorials on Aggregation??
- Prev by Date: find the minus Key
- Next by Date: Re: find the minus Key
- Previous by thread: Re: Articles or Turorials on Aggregation??
- Next by thread: Re: Articles or Turorials on Aggregation??
- Index(es):
Relevant Pages
|