Grokking SOLID Design Principles
Ask Author
Back to course home

0% completed

Vote For New Content
Can SRP lead to high coupling?

necas.radek

Dec 13, 2024

Hi, I like this course and how are different principles linked together in this part. I wanted to discuss the part where implementing SRP leads to low coupling. I think it can when it is doing well, but sometimes it might have an opposite effect. For example you have legacy code with class A with many responsibilities. You separate some responsibilities into new class B. But now class B can easily become tightly coupled with A because it was created (extracted) based on requirements of A. It can happen also when junior developers try to implement SRP blindly to their design. They have bigger functionality or use case. To implement it with SRP in mind they need to create classes with different responsibilities. But each class is then tightly coupled to the rest because it was created for this single purpose. I've seen this quite often happened for juniors of this concept. Do you have similar experience? And do you have any strategy or pattern aim at this problem?

0

0

Comments
Comments

On this page

What is Coupling?

General Example: Tightly Connected Devices vs. Independent Devices

High Coupling in Code: One Class Doing Too Much

Reducing Coupling: Separate Database Logic from Student Class

Coupling and SRP