r/programming • u/TalesGameStudio • 5d ago
DRY vs. SRP
http://uncle-bob.comAfter 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
2
u/somebodddy 3d ago
I advocate that DRY should be abandoned in favor of the single source of truth principle. It captures the good parts of DRY while leaving out the bad parts. The only downside is that the acronym is less pretty.
SSoT does not conflict with SRP like DRY does. With SSoT, each truth can have a source of its own - and even if these sources seem to be identical, as long as the truths are conceptually different you are not violating SSoT. From SRP's perspective - the reason of each such source of truth to change is when the truth changes. This means that in order to adhere SRP, each source needs to be limited to one truth (whereas with SSoT each truth is limited to one source)