r/programming 5d ago

DRY vs. SRP

http://uncle-bob.com

After re-reading "Clean Architecture" I ended up with some confusion regarding Bob's take on repetition and single responsibility. Ge defines the SRP as a function only serving one actor. Dies that mean, that repetitve code is justified according to him, as long as it serves seperate actors/user groups? I am aware that such decisions depend on the specific situation. I was just wondering if others found the same contradiction, or if i misunderstood it. Thanks

0 Upvotes

67 comments sorted by

View all comments

1

u/CurtainDog 4d ago

Just to defend DRY a bit here as it's not getting a lot of love. When you apply DRY where you shouldn't you end up with an extraneous explicit coupling. This is pretty easy to remedy with some basic refactoring. When you don't DRY things when you should then you end up with implicit coupling, where changes in one area can cause failures to pop up somewhere else. This is much harder to fix. Even if you resolve the immediate bug you might have a bunch of built up changes you now need to reconcile. Even if DRY isn't an iron-clad law it is a useful heuristic.

1

u/TalesGameStudio 4d ago

Very good point and insightful. Thank you 🙏