[Newbies] Best place to ask Smalltalk questions?

Ron Teitelbaum Ron at USMedRec.com
Thu Aug 7 14:14:19 UTC 2008

Hi Sean,

> ok i have another. lets take something that in a sql
> driven environment would be a lookup table.
> countries and states. what the the smalltalk way with this?

There are a number of patterns for this.  Not all of them are strictly
object oriented.  The easiest way to do this is to use a database to hold
and coordinate the data.  Then you would query for the data and instantiate
objects as needed (and maybe cache some frequently used ones).

Your suggestion of using a class variable or a class method that is
responsible for creating all of your instances also makes sense.  You can
either build all the instances and save them in your image or build the
instances during startup or lazily when needed.  You need to have some root
to hold those new instances to keep them from being garbage collected.  This
can also be done with a class variable.  Just set a class variable to a
collection of your instances, then use that variable to lookup your

Having an external file is also a good way to go.  The same issues arise
from the file as for putting the data in a method, but benefit of using the
file is that your data is not saved in code and can be updated without
changing your running image, although your image needs to know when the file
changes so that it can refresh your instances.  

Hope that helps,

Ron Teitelbaum

More information about the Beginners mailing list