S.O.L.I.D Principles

Brief Explanation About S.O.L.I.D Principles

S.O.L.I.D Principles

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:

  1. S — Single Responsibility Principal
  2. O — Open-Close Principle
  3. L — Liskov Substitution Principle
  4. I — Interface Segregation Principle
  5. 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