May 2018
Intermediate to advanced
300 pages
7h 35m
English
The Liskov Substitution Principle (LSP), which can sometimes referred to as Design by Contract, is the third of the SOLID principles and was first put forward by Barbara Liskov. LSP states that a derived or subclass should be substitutable for the base or superclass without having to make modifications to the base class or generating any runtime errors in the system.
LSP can be further explained using the following mathematical notation—let S be a subset of T, an object of T could be substituted for an object of S without breaking the existing working functionalities of the system or causing any type of errors.
To illustrate the concepts of LSP, let's consider a Car super class with a Drive method. If Car has ...