Questions tagged [liskov-substitution]

For questions about Liskov substitution principle in object-oriented design.

Principle to design subtypes that are safe to substitute instead of supertype, that is code intended to work with supertype keeps functioning as expected when handling objects of subtype.

See also:

  • tag
  • Wikipedia article: Liskov substitution principle

    Substitutability is a principle in object-oriented programming. It states that, in a computer program, if S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may substitute objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.). More formally, the Liskov substitution principle (LSP) is a particular definition of a subtyping relation, called (strong) behavioral subtyping...

96 questions
5
votes
4 answers

Liskov Substitution Principle in Clean Architecture

Sorry for the unspecific title but I can't find a concise way to state my issue. I am reading the book Clean Architecture, by Robert C. Martin. It has a short chapter about the LSP with a couple examples, but I am unable to understand why the first…
raven
  • 285
1
vote
3 answers

How to avoid breaking LSP when specialising (MVC) classes?

This has really nothing to do with MVC but I came across the issue and also found a related question in that context. Unfortunately the related question fell short of describing where the LSP violation occurs in its original example and thus did not…
Lukas
  • 119