Variable inheritance
kosh
kosh at aesaeion.com
Tue May 22 04:46:24 EDT 2001
Magnus Lycka wrote:
> Roman Suzi wrote:
>> Multiple inheritance says it bad design.
>
> I wouldn't say that in general. But most of the
> time, and certainly in this case!
>
> The reasonable use of multiple inheritance is
> for so-called mixin-classes, that gives some
> particular behavior to a class. This can be used
> to give classes features such as persistence,
> automagic logging of some sort, or various support
> for debugging etc.
>
> Basically, inheritance is then used as an
> implementation device, and it has nothing to do
> with the more abstract _design_ classes. The mixin
> does not represent a real world object that would
> pop up during requirements capture, analysis or
> early design.
>
Yes that is a great use of MI. Using mixins for behavior is extremely
common in zope. It works very nicely be able to gain ACL capability by
inherting from the RoleManager or gain full persistance in the ZODB by
inheriting from Persist. Mixins work very nicely and I have used that
feature fairly commonly since it allows a better abstraction of various
workhorse functions from the design.
<snipped for brevity>
More information about the Python-list
mailing list