SOLID Principles

From JholJhapata

SOLID Principles are the 5 most important design principles when doing Object Oriented Programming(OOP). We should have a clear concept of this for developing software in a proper way to avoid a bad design.

It was introduced by Robert C. Martin.

When the developer builds a software following the bad design, the code can become inflexible and more brittle, small changes in the software can result in bugs. For these reasons, we should follow SOLID Principles. It’s intention is to make software designs more understandable, easier to maintain and easier to extend.

In this article, I will be covering these principles with examples of how they are violated, and how to correct them so they are compliant with SOLID Principles.

Concepts

Let’s go through each principle one by one:
S - Single responsibility principle
O - Open/closed principle
L - Liskov substitution principle
I - Interface segregation principle
D - Dependency inversion principle