Subclass vs Subtype

Of course, what the argument for substitition ignores is that child classes can override behavior in arbitrary ways. This, there is no guarantee that the child will act anything like the parent.

It is therefore useful to define two separate concepts. The idea of a subclass is simply a statement about definition, it claims that inheritance was used in the construction of the child class.

The concept of subtype talks about behavior, independent of construction. A class is a subtype of another if it preserves the behavior of the first.

The two are unrelated. It is easy to make subclasses that are not subtypes (by redefining a method without preserving behavior). It is also possible, although not as easy, to form subtypes that are not subclasses.

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