[Tutor] Objectifying code

Sean 'Shaleh' Perry shalehperry@attbi.com
Fri Jan 24 10:39:14 2003


On Thursday 23 January 2003 20:33, John Abbe wrote:
> Okay, i've read the syntax for coding objects in Python, but i'm new
> to using objects, and looking for your support on how to put them
> into use. If you'd like to help, please take a look at my
> GroupOwnedDatabase <http://ourpla.net/cgi/pikie?GroupOwnedDatabase>
> and suggest some ways of object-ifying it (it will grow, and want
> some kind of modularization), and/or reading that might help me learn
> how to do this.
>
> Thanks! Life,
> John

Dunno, after reading the code I am not but so sure objects are the right=20
solution.

There is some disagreement out in the world but I find that objects get m=
e one=20
of two things:

* joining data with methods to act on it and thereby making maintenance e=
asier

* hiding implementations to allow more plug and play style code and thus
  making trying out alternate solutions easier

Your PrintPerson seemed the most likely candidate for wrapping into a cla=
ss=20
followed by the authentication mechanism.  If find that sitting down and=20
writing out the data (nouns) in my code and then defining the actions (ve=
rbs)=20
tends to point out places where OO would be nice or convince me that=20
functions are good enough.

As a side critique there is a cgi module in Python which implements some =
of=20
what you have perhaps you should consider using it instead.