Liskov substitution principle
Liskov substitution principle
(programming, theory)Barbara Liskov first wrote it as follows: If for each objecto1 of type S there is an object o2 of type T such that for allprograms P defined in terms of T, the behaviour of P isunchanged when o1 is substituted for o2 then S is a subtypeof T.
A function that violates the LSP uses a reference to a baseclass and must know about all the derivatives of that baseclass. Such a function violates the open/closed principlebecause it must be modified whenever a new derivative of thebase class is created.
[Liskov, B. Data Abstraction and Hierarchy, SIGPLANNotices. 23(5), May 1988].