Liskov Substitution Principle with an explanation using Composition Over Inheritance
June 1, 2023
The Liskov Substitution Principle (LSP) is another important design principle in object-oriented programming. It’s named after Barbara Liskov, who introduced the concept in a 1987 paper. The idea behind LSP is that objects of a superclass should be able to be replaced with objects of a subclass without affecting the correctness of the program. In other words, if you have a piece of code that works with a superclass, you should be able to replace that superclass with any of its subclasses and the program will still work correctly.