Don't burn your base class

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
Line 6: Line 6:
  
 
In some cases, a designer can force a client to “burn” their base class by providing access to functionality or behaviours via inheritance only.
 
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==
 +
[[Replace Inheritance with Delegation]]

Revision as of 05:24, 21 September 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

Replace Inheritance with Delegation

Personal tools