[Newbies] Question about model, collection class choice

Tim Johnson tjohnson at iwu.edu
Wed May 4 15:27:25 UTC 2011


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.

How bad is it that I am keeping the date once in the object, and again as the key in the Dictionary?  Would it be better to only have the Date stored once, in the object, and then collect them some other way?  Say a Set, or an OrderedCollection?  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?

I like the readability and consistency of Dictionary>>at: aDate returning the object I want.  With an OrderedCollection or indexed variables or something it seems like the code would be less elegant, with maybe a lot of #select: and #collect: thrown in.  

I cannot collect these objects solely though #allInstances because I use the SMFileDatabase persistency mechanism which requires a root object to store.  I think I could use a class variable (or class instance variable?) for keeping track of the objects, in place of the singleton class, but I am fuzzy on that.

Any wisdom would be appreciated!

Thanks,
Tim



More information about the Beginners mailing list