These principles are not totally independent from each other. They work together, so a violation of one may very well mean violation of some other principles.

We implement SOLID principles with the help of design patterns.

S – Single responsibility principle

A class should have one and only one reason to change.

O – Open/Closed principle

Classes and methods should be open for extension, but closed for modification.

One way to implement this is to use decorator design pattern.

What does it mean?? It means that your classes should be designed such a way that whenever fellow developers wants to change the flow of control in specific conditions in application, all they need to extend your class and override some functions and that’s it.

For example, if you take a look into any good framework like struts or spring, you will see that you can not change their core logic and request processing, BUT you modify the desired application flow just by extending some classes and plugin them in configuration files.

L – Liskov substitution principle

Derived classes must be usable through the base class reference or interface without the need for the user to know the difference.

Derived types should be completely substitutable for their base types without breaking the functionality.

I – Interface segregation principle

The client should not be forced to depend on the methods they don’t use.

D – Dependency inversion principle

High level modules should not depend on the low level modules, both should depend on abstractions. Abstractions should not depend on details but details should depend on abstractions.