Subclass, Subtype and Substitutability

There are two terms that are similar, but slightly different. We use the term subclass to describe how something was constructed, it refers to an implementation technique. We use the term subtype to refer to a characteristic of behaviors, a subtype is a class that satisfies the principle of substitutability.

The two concepts are independent. In any language you can construct a subclass that is so radically different from its parent that it could not be substituted, this would be a subclass that is not a subtype. In some languages, such as Smalltalk, you can make two classes that behave in a similar fashion, even if they have no inheritance relationship. In such a situation we could say that one is a subtype to another, even if they are not subclasses.

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