[Newbies] Question about model, collection class choice

Ralph Johnson johnson at cs.uiuc.edu
Wed May 4 16:36:11 UTC 2011

On Wed, May 4, 2011 at 10:27 AM, Tim Johnson <tjohnson at iwu.edu> wrote:
> Hi everyone,
> I have a bunch of objects (all instances of the same class) which each hold a Date.  There is another singleton-style class which holds a Dictionary to keep track of those objects, where the key is the Date and the value is the object.

This is probably the most common way to do it.   #allInstances is
great for debugging, but I don't like using it for applications.

> Or is something smart going on, where the Date actually only exists once, and the key is internally some hash value, so my worry is misplaced?

This is not the way I would say it, but I think this is what is going
on.   Each Date can be referenced from many places.   The exact same
object is both the value of your object's date field, and also the key
in the dictionary.  Dates are not copied unless you explicitly copy
them.   Assignment is not copying in Smalltalk.

-Ralph Johnson

More information about the Beginners mailing list