Substition

Now we consider one of the most interesting ideas in object-oriented programming. The notion of substitution. Consider the following argument:

thus, if we look only at behavior, it seems like an instance of a child class ought to be suitable in any situation where an instance of the parent class is expected.

Following this line of thought leads to the idea that one should be able to declare a class as an instance of the parent class, and assign it a value from the child class.

This is the idea of substitution, sometimes termed liskov substitution.

[audio] [real] Text to accompany slide11, in Chapter 8 of An Introduction to Object-Oriented Programming