this post was submitted on 30 Oct 2024
510 points (99.6% liked)
Programmer Humor
32361 readers
423 users here now
Post funny things about programming here! (Or just rant about your favourite programming language.)
Rules:
- Posts must be relevant to programming, programmers, or computer science.
- No NSFW content.
- Jokes must be in good taste. No hate speech, bigotry, etc.
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
I find DRY often turns into an antipattern because decoupling is far more important than code reuse in practice. Having a function that supports many different code paths can make it very brittle because any changes to it need to consider all the possible use cases. However, if you have two separate functions that are similar, but can evolve independently then you don't have that problem. As a rule, it's better to duplicate code first, and then extract parts that turn out to be general purpose functionality once that's identified through usage, and to put that code into libraries.