On Sat, Oct 27, 2007 at 09:51:52PM -0400, John Almberg wrote:
Hi Ron,
In a nutshell, I have an application that needs to read Items from a database.
I recently discovered that in Smalltalk classes are real objects. This struck me as cool, so when I was deciding how to instantiate these Items, I thought, hey I'll use the class object as a factory (actually, I think it's more of an adapter pattern, but...)
<snip>
So, I think it was a case of falling in love with a cool feature, and then mis-applying it, just because it was dying to be used.
On the contrary, it sounds to me like you approached the problem in exactly the right way. You correctly observed that classes can serve as factories, so there was no need to invent something new for that purpose. You used that understanding to implement a simple solution that worked well, and when you encounted a need to support additional complexity, you refactored your system to do so. Well done.
One of the things that makes Smalltalk an enjoyable environment is that it does not force you to completely understand a problem before you get started solving it. You can start simply and move things around later on as you improve your understanding and discover your mistakes.
Hope this explains it... I'm afraid I don't always get the jargon right, but that's why I'm a newbie, I guess!
If you like to think in terms of design patterns, "Smalltalk Best Practice Patterns" by Kent Beck is a very useful guide.
Dave