Just wanting some general wisdom on object modeling.
I am creating a person object for a website I am building.
Inside this person there is much data desired/required. Some of it very simple but I could easily see an explosion of instance
variables.
My naive instinct is to create/model other objects even if
very small
to satisfy the needs.
example:
instead of instance variables: dateOfBirth placeOfBirthCity placeOfBirthState yearOfBirthPublic ...
I would create a class/object for BirthInformation with those variables and in my person object have a birthInfo variable.
Is this a correct way to do this in Squeak or am I off base? I have lots of such types of data.
Any wisdom greatly appreciated.
Thanks.
Jimmie
Personally, I would just throw the inst vars in there and start doing stuff. As you continue building you will probably notice certain synergies and places where you realize some of those instVars actually look more like a separate class.
For me, building in Smalltalk is about very quickly making stuff the first way I think of and refactoring as I go until I have something that I like, and does everything it needs to.
I agree. Jimmie, don't be afraid of making objects, but be sure you're making them for behavioral reasons and not simply to make clean looking data structures.
Think less about the data and more about the behavior such an object would display. What would a BirthInfo do? If the answer is belong to a Person, then you don't yet have any reason to make such an object. Hopefully you already have an idea of what a person will do.
Ramon Leon http://onsmalltalk.com