OOP SOLID Design principles

S — Single Responsibility Principle (known as SRP)

The name itself suggest that the “class should be having one and only one responsibility”.

O — Open/Closed Principle

This principle suggests that “classes should be open for extension but closed for modification”

L — Liskov’s Substitution Principle

This principle suggests that “parent classes should be easily substituted with their child classes without blowing up the application”. In other words every subclass or derived class should be substitutable for their base or parent class.

I — Interface Segregation Principle

This principle suggests that “many client specific interfaces are better than one general interface”. In other words a client should never be forced to implement an interface that it doesn’t use, or clients shouldn’t be forced to depend on methods they do not use.

D — Dependency Inversion Principle

This principle suggest that “classes should depend on abstraction but not on concretion”. The Dependency Inversion Principle (DIP) states that high-level modules/classes should not depend on low-level modules/classes. Both should depend upon abstractions. Secondly, abstractions should not depend upon details. Details should depend upon abstractions.

Leave a comment