Split class across multiple files
Diez B. Roggisch
deets at nospam.web.de
Fri Nov 20 11:31:27 EST 2009
eric.frederich schrieb:
> I have a class which holds a connection to a server and a bunch of
> services.
> In this class I have methods that need to work with that connection
> and services.
>
> Right now there are about 50 methods some of which can be quite long.
> From an organizational standpoint, I'd like to have method
> implementations in their own files.
>
> Is this possible? It is recommended? Should I just stop worrying
> about it and have a 5,000 line class?
It is pretty easy to do, as python allows multiple inheritance. Just
group together methods into a class, and create one that inherits from all.
However, I'd say something that even splitted up is essentially one
class with 5000 lines cries for a huge refactoring. Of course this
depends on the use-case, but I for once don't have a single such beast.
Looks like a god-object to me...
http://en.wikipedia.org/wiki/God_object
Diez
More information about the Python-list
mailing list