Don't burn your base class

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
Line 8: Line 8:
  
 
==Refactor With==
 
==Refactor With==
[[Replace Inheritance with Delegation]]
+
*[[Replace Inheritance with Delegation]]
 +
 
 +
==See Also==
 +
*[[Avoid inheritance for implementation]]

Revision as of 07:50, 5 October 2008

This is a comment on the use of inheritance, and is especially applicable to object-oriented programming languages that employ a single inheritance model.

A designer has “burned” their base class when they have, perhaps unnecessarily, used inheritance to access the attributes and / or behaviours of another class. In a single inheritance model, they have consumed or “burned’ their one chance to inherit.

If a designer has “burned” their base class, it may be inferred that the designer has misused the inheritance model. This can be the case where the inheritance relationship does not represent a specialisation of the base class, or does not take advantage of polymorphism.

In some cases, a designer can force a client to “burn” their base class by providing access to functionality or behaviours via inheritance only.

Refactor With

See Also

Personal tools