Don't burn your base class
(New page: This is a comment on the use of inheritance, and is especially applicable to object-oriented programming languages that employ a single inheritance model. ==Have I burned my base class?==...) |
|||
Line 1: | Line 1: | ||
This is a comment on the use of inheritance, and is especially applicable to object-oriented programming languages that employ a single inheritance model. | 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. | 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. | |
− | + | ||
− | If a designer has “burned” their base class, it may be inferred that the designer has misused the inheritance model. This | + | |
− | + | ||
− | + | ||
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. |
Revision as of 23:50, 3 August 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.