Re:Don't write clean code, write CRISP code
by glanzwulf on Tuesday April 18, 2023 @09:35AM
(#35613801)
Funny enough this happened to me yesterday. I had to do a small change of code in a component and then when I pushed the code I got an error back. After searching for what was happening, it was actually a code I copied and named "Component2" two years ago when I was starting out. Today I would not have made it the way I did, but in my first month...
And thank god for github actions! :D
Re:Don't write clean code, write CRISP code
by orthoxerox on Tuesday April 18, 2023 @09:58AM
(#35614125)
Premature dryness is the real issue, not the principle itself. When you catch yourself fixing the same code in multiple methods again, it's a good time to stop and refactor.
Re:Don't write clean code, write CRISP code
by senbrow on Tuesday April 18, 2023 @10:44AM
(#35614683)
DRY should really be "DRA" - don't repeat abstractions (which admittedly isn't as catchy).
The problem with DRY is when abstractions with currently identical implementations are given a single interface, even though they're logically distinct.
Then, when those distinct abstractions' implementations need to diverge, you've got a rats nest of references to manually pick through and separate out.
Or worse yet , the mistakenly-shared interface becomes parameterized, leading to a horrible mixing of requirements and concepts that may never be untangled if the original intent is lost to time.
Obviously DRY is great when you can consolidate multiple implementations that are actually a single abstraction, but it can really go off the rails if the motivation for the mantra isn't understood.
It's enough pain when the effort is too big to avoid (e.g. Js frontend, Rust Backend) it.
Juniors will learn the difference between actual and imagined similarities at some time.