Subtyping vs subclassing
Subtyping means subtype preserves all properties of supertype
Subclassing means subclass preserves class methods of super class, but may override their behaviour.
What does this mean?
Suppose we have a
set which extends from a super class
list. It still has the method
add which allows us to add an element to the list.
However, although it is a valid
subclass since it preserves all methods, the properties of set is different from list. It is no longer ordered. As such, it can’t be a subtype.