Backend & Runtime / Knowledge library
Liskov Substitution Principle
Requires subtypes to preserve the behavioral contract of their base type
Why learn Liskov Substitution Principle?
It makes polymorphic replacement safe for clients
The problem it solves
It prevents subclasses from weakening expectations or adding surprises
Where it came from
Liskov Substitution Principle is a software design principle that requires subtypes to preserve the behavioral contract of their base type. Its guarantees and tradeoffs depend on the concrete implementation and operating context.
Build your understanding
Work through these exercises in order. Try the task before opening a reference.
- Define Liskov Substitution Principle and distinguish it from a neighboring concept.
- Choose a realistic task where Liskov Substitution Principle is appropriate.
- Identify a failure mode caused by misusing Liskov Substitution Principle.
- Interpret a small design or result involving Liskov Substitution Principle.
- Explain one tradeoff or limitation of Liskov Substitution Principle.
Documentation and sources
- Software Engineering at Google (abseil.io)