SOLID principles are probably the most important design principles in OOP languages like Java, Python, C#, etc.
But, more than 95% of programmers struggle to understand it.
Here's the Simplest Guide to Master SOLID principles:
But, more than 95% of programmers struggle to understand it.
Here's the Simplest Guide to Master SOLID principles:
1. Full form
S = Single Responsibility Principle
O = Open/Closed Principle
L = Liskov Substitution Principle
I = Interface Segregation Principle
D = Dependency Inversion Principle
Note: We will use Java to understand them
S = Single Responsibility Principle
O = Open/Closed Principle
L = Liskov Substitution Principle
I = Interface Segregation Principle
D = Dependency Inversion Principle
Note: We will use Java to understand them
2. Single Responsibility
A class should always have one responsibility and there should be only a single reason to change it.
A class should always have one responsibility and there should be only a single reason to change it.
3. Open Close
Class should be Open for Extension but Closed for Modification.
Class should be Open for Extension but Closed for Modification.
4. Liskov Substitution
Child Classes should be replaceable with Parent Classes without breaking the behavior of our code.
Child Classes should be replaceable with Parent Classes without breaking the behavior of our code.
5. Interface Segregation:
Interface should only have methods that are applicable to all child classes.
If an interface contains a method applicable to some child classes then we need to force the rest to provide dummy implementation.
Move such methods to a new interface.
Interface should only have methods that are applicable to all child classes.
If an interface contains a method applicable to some child classes then we need to force the rest to provide dummy implementation.
Move such methods to a new interface.
6. Dependency Inversion
Class should depend on abstractions (interface and abstract class) instead of concrete implementations.
It makes our classes de-coupled with each other.
If implementation changes then the class referring to it via abstraction won't change.
Class should depend on abstractions (interface and abstract class) instead of concrete implementations.
It makes our classes de-coupled with each other.
If implementation changes then the class referring to it via abstraction won't change.
That's a wrap!
I help people get started with Backend Development.
Follow me @vikasrajputin for more.
If you find this thread helpful then Like/Retweet the first tweet below:
I help people get started with Backend Development.
Follow me @vikasrajputin for more.
If you find this thread helpful then Like/Retweet the first tweet below:
Before you go, do you know?
I've already started writing on LinkedIn
I share some exclusive content there, which I never share here.
Follow me on Linkedin to stay updated with Backend content:
linkedin.com
I've already started writing on LinkedIn
I share some exclusive content there, which I never share here.
Follow me on Linkedin to stay updated with Backend content:
linkedin.com
جاري تحميل الاقتراحات...