How SOLID is a saviour? ( Single Responsibility)

 

Why Single Responsibility?

SOLID

S: Single Responsibility

O: Open-Closed

L: Liskov Substitution

I: Interface Segregation

D: Dependency Inversion

Do you know why SOLID? If not, this read might help you.

Here we will talk about why SOLID? Why we should practice SOLID? How it helps us? How it makes the complex life 🤯 of software developer easy 😌



Single Responsibility

A module should be responsible to one and only one actor

The best way to understand its need is by looking at the symptoms of violating it.

Let’s consider different actors using a common module.

Case 1: There can be a scenario where a developer who is responsible for one actor makes changes to the common function and deploys it to production.

But unfortunately, it doesn’t notice that another actor is also getting affected.

Now what? The production has a bug which has cost millions to the product.

See how it can cost millions.

Now considering each actor had its separate module, will the above issue occur? No.

Case 2: Consider developer 1 as the owner of actor 1 and developer 2 as actor 2. Both of them check out the code and started making changes to the common module code.

Now what? merge conflicts. Never-ending communication with other developers to understand their module change requirements.

How the above thing can be solved by having one module which handles one actor. That is the Single Responsibility Principle for developers.

So here it was for S in SOLID.

Copyright © 2023 fintechcoddler.blogspot.com

Let's discuss and grow.
Can also let me know what article you want to discuss in the next blog.

Post a Comment (0)
Previous Post Next Post