Single Responsibility Principle (SRP)
- A class should have only one reason to exist
Open Closed Principle (OCP)
- Open to extension, closed to modification
- Can extend feature without modification
- Replace if-else with interface + polymorphism
Liskov Substitution Principle (LSP)
- Subclass should extend the capabilities of superclass
- A.k.a. semantic subtyping
Interface Segregation Principle (ISP)
- Must not implement unnecessary interface
- Interface should be segregated based on usage
Dependency Inversion Principle (DIP)
- Entities must depend on abstraction, not concrete implementation
Back