539
submitted 4 weeks ago by davel@lemmy.ml to c/programmerhumor@lemmy.ml
you are viewing a single comment's thread
view the rest of the comments
[-] yogthos@lemmy.ml 5 points 3 weeks ago

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.

this post was submitted on 30 Oct 2024
539 points (99.6% liked)

Programmer Humor

32576 readers
643 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS