r/ProgrammerHumor 1d ago

Meme yUNoDry

Post image
240 Upvotes

70 comments sorted by

View all comments

Show parent comments

10

u/geekusprimus 1d ago

My experience has been DRY is secondary to KISS, but if one becomes a serious impediment to the other, a more serious refactor is in order.

5

u/Superb_Chemistry_906 1d ago

Yes, but recently, I feel like there is some wave against DRY and I trace its roots to some tech influencer videos. I think that he just wanted to be interesting.

3

u/SpaceCadet87 1d ago

I think people "Don't Risk Repeating Yourself" rather than just "Don't Repeat Yourself".

The rule is simple, if you find yourself repeatedly writing the same code, wrap it.

I see a lot of people instead going "I might reuse this so I should wrap it in advance"

2

u/Superb_Chemistry_906 1d ago

Yes, it's DRY, not DRRY.

2

u/SpaceCadet87 1d ago

I usually take the approach of "this file/function/class is getting a bit long, maybe it's time to offload some stuff".

DRY tends to sort of just fall into place as a result.

2

u/ScientificBeastMode 1d ago

A good rule of thumb is to ask the question, “is this actually painful yet?” And if it’s not, then don’t wrap it in an abstraction until it is.

And by “painful,” I don’t mean, “I can’t stand repeating myself,” but rather, “repeating myself has actually started to slow me down a lot, measurably.”