liskov-substitution-principle
Installation
SKILL.md
Liskov Substitution Principle (LSP)
Overview
Subtypes must be substitutable for their base types without altering program correctness.
If S is a subtype of T, objects of type T can be replaced with objects of type S without breaking the program. Subclasses must honor the contracts of their parent classes.
When to Use
- Creating a class that extends another class
- Overriding methods from a parent class
- Implementing an interface
- Feeling like you need to throw exceptions in overridden methods
- Inheritance hierarchy feels "forced"