Idealized Image of Inheritance
Much of the power of object-oriented techniques will come about from
a purposeful confusion between a parent and child class, and the
ability to substitute an instance of a child class where we are expecting
an instance of the parent class. We call this the principle of
To see why the principle of substitutability should be valid, consider
the following argument:
- Instances of the subclass must possess all data areas associated with
the parent class.
- Instances of the subclass must implement, through inheritance at least
(if not explicitly overridden) all functionality defined for the parent
class. (They can also define new functionality, but that is unimportant
for the present argument).
- Thus, an instance of a child class can mimic the behavior of the parent
class and should be indistinguishable from an instance of the parent
class if substituted in a similar situation.
Intro OOP, Chapter 7, Slide 6