SOLID is a signifier for five design principles that are necessary for OOP. (Object-Oriented Programming) Robert C. Martin introduced these five principles. As a computer programmer, you need to know what these five principles are and able to understand and use them in everyday codes. In this article, basic knowledge regarding SOLID principles is going to be given.
The 5 SOLID principles are:
- S — Single Responsibility Principal
- O — Open-Close Principle
- L — Liskov Substitution Principle
- I — Interface Segregation Principle
- D — Dependency Inversion Principle
Single Responsibility Principal
A class should have one and only one reason to change, meaning that a class should have only one job.
Open-Close Principle
Objects or entities should be open for extension but closed for modification.
Liskov Substitution Principle
This means that every subclass or derived class should be substitutable for their base or parent class.
Interface Segregation Principle
Clients should not be forced to implement methods they do not use
Dependency Inversion Principle
Higher-level modules shouldn't depend on lower-level modules, however, they must depend on abstractions