Introduction to OOP
Chapter 10: Subclasses and Subtypes:
The Substitution Paradox
There is a curious paradox that lies at the heart of most strongly typed object-oriented programming languages.
Substitution is permitted, based on subclasses. That is, a variable declared as the parent type is allowed to hold a value derived from a child type.
Yet from a semantic point of view, substitution only makes sense if the expression value is a subtype of the target variable.
If substitution only makes sense for subtypes and not for all subclasses, why do programming languages based the validity of assignment on subclasses?
, Slide 07