Moving to an OOP model from an classically imperitive one

Gregory Ewing greg.ewing at canterbury.ac.nz
Wed Apr 23 20:26:46 EDT 2014


Ian Kelly wrote:

> How 
> about adding one abstract class per file, and then letting 
> SubuserProgram inherit from each of those individual classes?

I'd recommend against that kind of thing, because it makes
the code hard to follow. With module-level functions, you can
tell where any given function is coming from by looking at the
imports (as long as you haven't used 'import *', which is a
bad idea for this very reason).

But if you're looking at a method call on a class that
inherits from half a dozen base classes, it's hard to tell
which class it's implemented in.

In other words, massively multiple inheritance is the OO
equivalent of 'import *'.

The same goes for any scheme for injecting methods into a
class after defining it, only more so, because the reader
won't be expecting weird things like that.

-- 
Greg



More information about the Python-list mailing list