SOLID-Liskov Substitution Principle
Details
- Full Name
-
SOLID Liskov Substitution Principle (LSP)
Intent:
Subtypes must be substitutable for their base types without altering the correctness of the program. Derived classes must honor the contracts of their base classes.
When to Use:
-
Subclass overrides break expected behavior of the base class
-
instanceof/type checks appear in client code
-
Inheritance hierarchies violate "is-a" relationships
Prompt Example:
"Überprüfe diese Vererbungshierarchie auf Verletzungen des SOLID-Liskov Substitution Principle."
Related Anchors:
-
SOLID Principles (Umbrella)