SOLID Principles
Table of Contents
1. Overview
Set of Rules for guiding writing maintainable object oriented code
- Single Responsibility (SR):
- A class should only have one reason to change.
- Enhances code maintainability and reduces complexity.
- Open/Closed (OC):
- Software entities (classes, modules, functions) should be open for extension but closed for modification.
- Promotes code reusability and flexibility.
- Liskov Substitution (LS):
- Objects of a superclass should be replaceable with objects of a subclass without affecting the correctness of the program.
- Ensures that subclass implementations uphold the behavior of the parent class.
- Interface Segregation (IS):
- No client should be forced to depend on methods it does not use.
- Aims to reduce the impact of changes by keeping interfaces small and specialized.
- Dependency Inversion (DI):
- High-level modules should not depend on low-level modules. Both should depend on abstractions.
- abstractions should not depend on details. Details should depend on abstractions.
- Aims to reduce coupling between different components of a system.