Object oriented design question: classes with mulitiple functions or multiple classes?

Blake Winton bwinton at tor.dhs.org
Thu Mar 23 17:02:00 EST 2000


In comp.lang.python, you wrote:
>First off a confession, I have always been dreadful at object oriented
>design.

Ditto, but I seem to be getting better with experience.
And the Design Patterns book helped.

>I have one master class called customerdisplay.
>
>My question is this: Am I better off creating initialization functions
>to initialize and control all of the widgets, or should I create a class
>for each page of the notebook and build my display using smaller class
>entities?

I was working on an entirely different project.  It had nothing in
common.  But I also had a since "Master Class", with many functions.
Eventually, as the requirements changed, the class became 1400 lines
long.  Then it was a total mess.  So the company refactored it so
that each function was a "Command" (a separate class, containing a
single "execute" method), and since then, whenever the client has
wanted to add new functionality, all we had to do was add another
class, and test it, instead of making our "Blob" class even bigger,
and having to re-test everything.

All the utility functions, that weren't called by anyone else moved
into the Base Command Class.  It turned out to be much nicer, since
each class is very small, and only does one thing.  And they tend
not to call each other.

These days, I get worried when I hear terms like "Master Class".  ;)

Later,
Blake.
-- 
4:20pm up 23 days, 19:12, 1 user, load average: 1.00, 1.00, 1.00




More information about the Python-list mailing list