An introduction to Liskov substitution principle (LSP)

This post is about the Liskov substitution principle (LSP). This is also the third of my posts about SOLID principles, following the posts I wrote about DI and ISP in the past few weeks. What is Liskov substitution principle (LSP)? This principle is based on Barbara Liskov’s definition of subtyping, commonly known as the Liskov substitution principle which states the following: if S is a subtype of T, then objects of type T in a program may be replaced with objects of type S without altering any of the desirable properties of that program or in my own words, in programming we…