in reply to Re^4: An object replacing itself
in thread An object replacing itself

It is better design. You've separated your concerns when you keep your collection separate from the thing the collection contains. This is a bit like a box that contains other boxes that also contains itself. The primary thing here is to keep the collection object separate from your contained object. Or also, to keep the container out of the things that it contains. You might, if you wished, provide a method on your collection which could do the ->next operation for you.

Replies are listed 'Best First'.
Re^6: An object replacing itself
by ryantate (Friar) on Sep 23, 2004 at 21:53 UTC

    None of my objects contains a reference to itself. One object contains a reference to the objects that come after it in a collection. When the next object is loaded, the list is shortened by one and transferred over.

      That still makes the object a container object. They should only be there if they are intrinsic to the object. If they don't belong to it, they shouldn't be in its possession.

        ... in your opinion ;->

        I see what you're saying, I have to think about whether I agree. I don't think it's nearly as clear cut as to be objectively called "better," but maybe I'll change my mind :-]

        Thanks again.