- The Liskov Substitution Principle (LSP) is more than just a rule for inheritance; it applies to any substitution of functions or code, including version updates.
- LSP requires that a subtype's methods have weaker or equal preconditions and stronger or equal postconditions compared to the supertype.
- The principle also includes satisfying state invariants and history properties of the supertype.
- When modifying APIs, weakening preconditions or strengthening postconditions is safe, while the opposite can break existing code.
- Hyrum's Law warns that any observable behavior of a system may be depended on, so explicit postconditions are crucial for maintaining compatibility.