Well factored Objects
Christian.Hofer at gmx.de
Tue Apr 29 13:20:10 UTC 2003
Allow me to make just some general remarks concerning OO analysis:
> From: Jimmie Houchin <jhouchin at texoma.net>
> I am wanting/trying to move some homebrew software I wrote at work in
> MSWorks to Squeak. It is a database application.
Porting a non-OO software to Smalltalk is a really hard job: You have to
switch from thinking in data structures to thinking in objects and rethink
*everything*. I don't envy you for the task you want to do.
> It is a person database with close to 200 fields. Not all fields are an
> attribute of person, but I am very contrained with MSWorks. Alas, it was
> all I had available.
What is a database? If you know, try to forget it for the moment. The
question is: what is the data used for? Don't think about storage of data - there
is the image, that is all for now, care about the details later...
> The JHPerson class could easily have dozens of instance variables. But
> what I had been thinking is to group common variables into new classes
> similar to but not necessarily exactly:
> JHPersonName (first, middle, last, maiden, suffix)
> JHPersonBirth (date, place)
> JHPersonDeath (date, place)
> JHPersonMarriage (list of (dates, places, spouses))
> JHPersonAddress (street, city, county, state, zip)
> JHPersonOccupation (title, industry)
> JHPersonEducation (numYears, listOfSchools)
> ... lots more data ...
You are listing a data structure, not a collaboration of objects. The
question is: What are the tasks you want to do that you need all that data for?
Forget about most of the data first (you can add it later) and ask for
responsibilities: What shall a "Person" be able to do? Or try it the other way around:
e.g. what is it, that I do with the information which education a person
has? The answer names a responsibility and the follow-up question is: which
object should carry that responsibility. Draw CRC-Cards and play with them. First
figure out what an object can do (and this shouldn't be: "Show me the date
of birth", but e.g. "Notify me if somebody has birthday today") and then ask
what it has to know in order to accomplish its tasks.
+++ GMX - Mail, Messaging & more http://www.gmx.net +++
Bitte lächeln! Fotogalerie online mit GMX ohne eigene Homepage!
More information about the Squeak-dev