Skip to content
- SRP -> Single Responsibility Principle
- OCP -> Open/Closed Principle
- LSP -> Liskov Substitution Principle
- ISP -> Interface Segregation Principle
- DIP -> Dependency Inversion Principle
Single Responsibility Principle
- A class should have only one reason to change.
- There should be never be, more than one reason for a class to change.
- We should design a class in such a way that there should not be more than one responsibility associated with a class.
Open Closed Principle
- Opening up for extension, closing it down for modifications.
- Modules should be opened for extension but closed for modifications.
Liskov Substitution Principle
- Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.
- Functions that use references of the base class must be able to use objects of derived class even without knowing them.
- Always program in interfaces.
- A subclass should behave in such a way that it will not cause problems when used instead of the superclass.
Interface Segregation Principle
- Many client-specific interfaces are better than one general-purpose interface.
- Clients should not be forced to depend upon interfaces that they don’t use.
Dependency Inversion Principle
- High level modules should not depend on the lower level modules.
- One should depend upon Abstractions. Do not depend upon concretions.
- Never derive from concrete class, derive from interfaces.