The Liskov replacement principle (LSP) states that if an object o1 is a type S and it can be replaced by an object o2 which is a type T without violating the initial behavior (s) of all its users, then S is a subtype of T.
A common example used to display an LSP violation is Rectangle and its derived type Square. The argument is that although intuitively the square seems to be a subtype of the Rectangle, there is some Square behavior that differs from the Rectangle. The conclusion is that Square cannot be a subtype of Rectangle LSP.
All the explanations that I have found are ending, and I think this is not useful. I want to know what should I do if I have this problem? Create an S, which is not a subtype of T, and then what? What solutions can I solve?
Can someone please enlighten me with the answer to the impending question?
edit .. Instead of giving an example here, I refer you to this article .
source
share