An Argument for Substitution
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. It therefore seesm reasonable that a variable declared
as a parent, should be able to hold a value generated from the child class.
Intro OOP, Chapter 8, Slide 11
The principle of substitutability is sometimes called Liskov
substitutability, since one of the first people to describe the idea
was Barbara Liskov, of MIT.