A design problem I met again and again.

Carl Banks pavlovevidence at gmail.com
Thu Apr 2 13:51:30 EDT 2009


On Apr 2, 8:02 am, 一首诗 <newpt... at gmail.com> wrote:
> You get it.  Sometimes I feel that my head is trained to work in a
> procedural way.  I use a big class just as a container of functions.
>
> About the "data-based" approach, what if these functions all shares a
> little data, e.g. a socket, but nothing else?

Then perhaps your problem is that you are too loose with the
interface.  Do you write new functions that are very similar to
existing functions all the time?  Perhaps you should consolidate, or
think about how existing functions could do the job.

Or perhaps you don't have a problem.  There's nothing wrong with large
classes per se, it's just a red flag.  If you have all these functions
that really all operate on only one piece of data, and really all do
different things, then a large class is fine.


Carl Banks



More information about the Python-list mailing list