Design patterns·Objects, messages and the principles
the subclass threw on a method the parent promised, and every caller written against the parent was suddenly wrong.
Liskov substitution principle
Also calledLSP, Liskov substitution, substitutability
The rule that an instance of a subtype must be usable anywhere the supertype is, without the caller having to know. Violations are easy to spot once you know the shape: a subclass that strengthens a precondition, weakens a guarantee, or throws where the parent returned. The square-and-rectangle example is the standard illustration, but the version you meet in real code is a read-only collection that inherits from a mutable one.