When we look at the history of SOLID, we don’t need to go far. It was first introduced by Michael Feathers in the early 2000s and later renamed ” SOLID ” by Robert C. Martin as the acronym of the first five principles of object-oriented programming and design.
These principles enable software developers to create more understandable, developable, manageable and reusable software to prevent code complexity in developed projects.
The purpose of SOLID principles is to enable us to write codes that can be adapted to these changes with minimum effort, rather than making us better programs. If we do an object-oriented program, we should be writing codes that comply with these 5 principles accepted as the standard in the world.
A class should have only one job and should be responsible for it. For example, a Logger class that you make to keep a Log should be responsible for Log operations only.
The objects or entities we write in the application must be open to development and closed to change. If you want to expand the method that you have written before, it is necessary to write more manageable and extensible codes when needed by using interface or abstract classes.
Lisk Substitution Principle
For the Liskov principle, we can briefly call it the replacement principle. It says that the classes derived from a base class can be used instead of the upper classes when needed.
Interface Segregation Principle
Clients should not be forced to use an interface that they do not need, or they should not implement the entire interface’s methods for a single method of the interface it needs. The Interface Segregation principle says that in such cases, disconnect your interfaces and do not overload tasks on an interface. In this way, the client does not need to implement any method to develop will not have to.
Dependency Inversion Principle
According to this principle, one class should not be directly dependent on another class. The connection between them must be achieved through an abstract concept. This abstract concept can be either an interface or an abstract class.