this post was submitted on 20 Dec 2024
96 points (92.9% liked)
Programming
17680 readers
58 users here now
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Rules
- Follow the programming.dev instance rules
- Keep content related to programming in some way
- If you're posting long videos try to add in some form of tldr for those who don't want to watch videos
Wormhole
Follow the wormhole through a path of communities !webdev@programming.dev
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Name some great "simple principles;" everything has nuance and trying to distill things into "well it's just this simple principle..." is a great way to get catastrophic mistakes.
You did not understand the point of that article if you think it's about the dangers of over thinking. The issue with DRY is that it leads to making refractors without thinking about whether or not the refractor makes sense. That's the exact issue the author is warning about, think about whether or not dry makes sense.
That has ABSOLUTELY NOTHING to do with how many times the code has been repeated. It has everything to do with why it's repeated.
I'll toss that right back at you bud. You don't seem to understand the actual problem.
It does not. I literally fixed a bug today because the same algorithm, doing the same job, was used in two different places formatted differently, exactly two, and they got out of sync resulting in memory corruption.
That's what DRY is intended to fix. Not "I have three [or whatever number] things doing the same thing so now I should DRY this code up", I've seen HORRIBLE refractors from DRY applied to 3 things; absolute spaghetti inheritance hierarchies that were "DRY."
I hate talking about DRY because it's this principle that so many people think "oh I'm doing it correctly; I'm doing good things!" and they actually make the code SO MUCH worse.
EDIT: Here's exact quotes from the article (emphasis theirs):