Liskov Substitution Principle¶
Subtypes must be substitutable for their base types without altering program correctness, because type hierarchies encode behavioral contracts, not just structural similarity.
Tension Addressed¶
Inheritance vs. Composition
Recognizable As¶
Type hierarchies where any subclass can replace the parent; interfaces that specify behavioral preconditions and postconditions; violations manifest as code checking types before operating
Canonical Sources¶
Liskov & Wing, "A Behavioral Notion of Subtyping" (1994); Liskov, "Data Abstraction and Hierarchy" (1987)
Transfers To¶
Type Systems (behavioral subtyping), API Design (contract compatibility), Testing (mock substitutability)
Classic violations include Square extending Rectangle (changing width changes height, violating Rectangle's postconditions) and throwing exceptions for "unsupported" inherited methods. Both indicate inheritance was used for code reuse rather than behavioral subtyping.