Image for Liskov Substitution Principle

Liskov Substitution Principle

The Liskov Substitution Principle states that objects of a base class should be replaceable with objects of its subclasses without affecting the correctness of the program. In other words, subclasses should behave in a way that doesn't break the expectations of the base class's interface. This ensures that you can substitute a specific type with a more specialized version seamlessly, maintaining consistent behavior and reliability in the system. It promotes designing classes so that extending them doesn’t introduce unexpected issues when used in place of their parent classes.