SOLID Principles
Contents
These are one of the oldest guidelines of system design. But they are very much applicable even today
1 The Single Reusability Principle
- It states that a group of functions in a module/ file should have only one reason to change.
- Restating, Code that changes together lives together.
- Make the software system follow the hierarchy of the organization not allow them
2 The Open-Closed Principle
- Make software systems easy to be changed by ability to allow changes by adding new code over changing existing code.
- Create a new class by extending a class over adding more functions to the existing class
3 The Liskov Substitution Principle
- A software should be designed using interchangeable parts (Plugin architecture) And the interchangeable parts need to be follow rules specific to that plugin.
- In terms of OOPs All interchangeable classes need to implement the same interface.
- Due to this, the classes that are dependent on these interchangeable classes will always have the data/ methods that they depend on.
4 ISP: The Interface Segregation Principle
- Do not depend on the things that you do not use.
- If it is necessary add interfaces between such relationships which will invert the dependency.
5 Dependency inversion principle
- Don’t refer to volatile concrete classes
- Don’t derive from volatile concrete classes.
- Don’t override concrete functions
- If any of these is necessary to be done create an interface and use it as an agreement which both need to always follow