From: Daniel T. on
lars_oberg(a)hotmail.com wrote:
> Daniel T. wrote:
> >
> > There are six different ways for A to use B. (Riel)
> >
> > 1) B is a parameter passed in with the message.
> > 2) B is provided by some other object C.
> > � �(Now we have to ask, "how did A get to the C object?")
> > 3) B is in some sort of globally accessible area.
> > 4) B is created within A's method
> > 5) B is given to A through some other message
> > � �and stored in one of A's attributes.
> > 6) B is created as part of the process of creating A
> >
> > The above quote is saying that a "collaboration" only occurs when A uses
> > B through means 2 or 3. I've never heard of such a restriction on the
> > term and I'm not sure what can be gained by making such a restriction.
>
> I guess 4 would be ok as well: New B().DoSomething() from within A's
> method as long as you do not use a temporary variable.

It's still a temporary even if you don't place it in a variable...

> Re. 3 above, it sounds like a static factory / singleton or similar.

Not a factory which returns a new instance every time it is used. That
would be (2) where the factory is the third-party object. If a static
function is being called (i.e., no object is involved,) then it would be
(4), but you are using a special creation method.

(3) is a singleton, flyweight or a global.