(LSP) Liskov Substitution Principle

The Liskov Substitution Principle (LSP) is one of the five principles of object-oriented programming known as SOLID principles. It states 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 a program is using a base class, it should be able to use any of its subclasses without knowing it, and the behavior should remain the same. The subclasses should be interchangeable with their base class and preserve the contract defined by the base class.

The LSP helps ensure that subclasses are properly derived from their base classes and that they behave in a way that is consistent with their base class. By following the LSP, developers can create flexible and scalable systems that are easier to maintain and extend over time.