Liskov Substitution Principle
Updated 2026-07-30
Summary
The Liskov substitution principle (LSP) is a particular definition of a subtyping relation, called strong behavioral subtyping, that was initially introduced by Barbara Liskov in a 1987 conference keynote address titled Data abstraction and hierarchy. It is based on the concept of "substitutability"…
Definition
Subclasses must be able to replace their base classes without causing errors in the program. That is, subclasses must not change the behavioral contract of the base class. Scaffold use: Maintain contract consistency. If you promise a service (base class), your upgraded version (subclass) must be fully compatible with the old functionality, and must not secretly reduce or change behavior, otherwise it will break user trust (system crash).
Introduction
How to use
Maintain contract consistency. If you promise a service (base class), your upgraded version (subclass) must be fully compatible with the old functionality, and must not secretly reduce or change behavior, otherwise it will break user trust (system crash).
Mechanism
The Liskov substitution principle requires that subclasses (subtypes) can seamlessly replace their base classes without breaking program correctness, meaning the behavioral contract must be compatible with the base class.
Practice
In progress 0/1Practice this model in one real situation:
Cases
- If a square overrides setting width to also set height, it breaks the substitutability of a rectangle, violating LSP.
Common pitfalls
- Mistaking 'can inherit' for 'should inherit'. LSP focuses on behavioral substitutability, not syntactic feasibility.
Sources
Source support: Explicit
References currently contain only Wikipedia links; primary sources still need review.
- en.wikipedia.orghttps://en.wikipedia.org/wiki/Liskov_substitution_principleverified
account_treeGenealogyexpand_more
PRIVATE NOTES · Only visible to you
SAVED Q&A
ENTRY Q&A · Private saving available
Ask with a clear boundary
thinkingmodels answers from published entry context only.
Your question is sent to thinkingmodels. The answer uses public entry context only.
RELATED MODELS