🏗️ SOLID Principles
Intermediate
What is the Barbara Liskov quotation that defines LSP?
Answer
Barbara Liskov's formal definition from her 1988 paper states: "If for each object o1 of type S there is an object o2 of type T such that for all programs P defined in terms of T, the behavior of P is unchanged when o1 is substituted for o2, then S is a subtype of T." In simpler terms: a program that works correctly with a Bird object must work correctly when any subtype of Bird is substituted, without knowing the concrete type. This is a stricter definition than mere structural substitutability (the "is-a" relationship) — it demands behavioral substitutability. The principle emphasizes that subtyping is about behavior contracts, not just method signatures, and is what distinguishes LSP from mere type inheritance.
More SOLID Principles Questions
View all →- Intermediate How would you refactor a class that violates SRP?
- Intermediate How does the Strategy pattern support OCP?
- Intermediate What are the conditions for LSP compliance?
- Intermediate How does ISP prevent "fat interfaces"?
- Intermediate What is the difference between DIP and dependency injection containers?