←back to thread

Against Best Practices

(www.arp242.net)
279 points ingve | 3 comments | | HN request time: 0.431s | source
1. jsbg ◴[] No.42173687[source]
The author sounds like even though they have read extensively about various "best" practices, they did not really gain an understanding of the tradeoffs involved with each one.

> “Don’t Repeat Yourself” (DRY) is basically good advice, but sometimes just copy/pasting things is just the more pragmatic thing to do, and not really a big deal.

Duplicating code on purpose is not about being pragmatic, it's about recognizing when DRY would violate the single responsibility principle.

The ability to weigh tradeoffs in context is what makes some engineers better than others.

replies(2): >>42175128 #>>42175968 #
2. layer8 ◴[] No.42175128[source]
The problem with DRY is that it is expressed incorrectly and misleadingly. There is little inherent benefit in avoiding code duplication, and it can do harm when done for the wrong reasons. The actual context is change management. Will the copy of the code likely have to change in the same way as the original? Only then should duplication be avoided. The rule taken literally fails to convey this important precondition and the reasoning behind it. (And so does WET.)
3. recursive ◴[] No.42175968[source]
> The author sounds like even though they have read extensively about various "best" practices, they did not really gain an understanding of the tradeoffs involved with each one.

It sounds to me like they did understand the tradeoffs. But that they were being brow-beaten to apply "best practices" that were inapplicable because of the tradeoffs.