The Liskov Substitution Principle

The Liskov Substitution Principle (or LSP) is one of the SOLID Principles, originally expressed by Barbara Liskov in 1988[BL1].
Although the authoritative sources express it in more formal language (see “Formally” below), it may be summarized as:

Clients of a Supertype S should be able to use instances of a Subtype T, without knowing it, and without undesired results.

Interestingly, the LSP is a Semantic principle, rather than a Syntactic one: as we can see in some examples (eg: “The Square/Rectangle Problem” below) the syntax of a language may be respected while breaking the LSP.

Square and Rectangle
Continue reading