Jun 20, 2012

Multiple Inheritance Best Practices

Multiple inheritance should be avoided: It can be replaced with some
design patterns.
  • super usage has to be consistent: In a class hierarchy, super should be used everywhere or nowhere. Mixing super and classic calls is a confusing practice. People tend to avoid super, for their code to be more explicit.
  • Don't mix old-style and new-style classes: Having a code base with both results in a varying MRO behavior.
  • Class hierarchy has to be looked over when a parent class is called: To avoid any problems, every time a parent class is called, a quick glance at the involved MRO (with __mro__) has to be done.

No comments: