SOLID Principles
S.O.L.I.D is an acronym for the five object-oriented design(OOD) principles defined by Robert C. Martin, popularly known as Uncle Bob.
S.O.L.I.D. STANDS FOR:
- Single responsibility principle
- Open closed principle
- Liskov substitution principle
- Interface segregation principle
- Dependency Inversion principle
Code implemented using these principles makes it reusable, maintainable and easier to test and scale.
Single Responsibility Principle(S.R.P)
A class should have one, and only one, reason to change. Change in requirements usually require code modifications in classes. If a class handles multiple responsibilities, the number of times it has to change increases. It will be only a matter of time until some change causes unexpected side effects to other functionalities.
Open-Closed Principle
You should be able to extend a classes behavior, without modifying it. This principle is the foundation for building code that is maintainable and reusable. Robert C. Martin
Liskov Substitution Principle
Derived classes must be substitutable for their base classes.
Interface Segregation Principle
Make fine grained interfaces that are client specific. Clients should not be forced to implement interfaces they do not use. Robert C. Martin
Dependency Inversion Principle
Depend on abstractions, not on concretions.