DRY is an over-rated programming principle?
gordonc.bearblog.dev
DRY is an over-rated programming principle?
1–10 of 501 posts
Re: DRY is an over-rated programming principle?
#2But I tend to agree with the author. Sometimes verbosity is the lesser evil. No suggestion should become a dogma and whoever played some games of code golf knows that short code doesn't mean code that is easy to read. Extreme example of course. But I believe many start to optimize in this way just as a way to reduce the line count.
Still, there is still room for some kind of factories or function templates (not in the c++ sense). I think a user is allowed to repeat himself but then again a user is just another arbitrary layer again. But if such helpers are to be implemented, I tend to like it in a place where the user is invoking said helpers and not on the level below that if that makes sense.
Re: DRY is an over-rated programming principle?
#3Re: DRY is an over-rated programming principle?
#4Especially if there is a very common refactoring bug and you get a pepperoni pizza instead of a pizza with one of the most natural toppings like pineapple. But I tend to agree with the author. Sometimes verbosity is the lesser evil. No suggestion should become a dogma and whoever played some games of code golf knows that short code doesn't mean code that is easy to read. Extreme example of course. But I believe many…
Re: DRY is an over-rated programming principle?
#5 left_toppings = ["beef"]
right_toppings = []
make_pizza([left_toppings,
right_toppings]) # this will be a very funny pizza
Holy cow I was not expecting a none pizza with left beef reference in code formRe: DRY is an over-rated programming principle?
#6Maybe.
But maybe you're falling prey to the other programmer trap - catering for conceivable situations that are just never going to happen, and making your codebase unnecessarily accommodating as a result. This is another great source of complexity, and quite often the source of unnecessary abstractions (which add to cognitive load) too.
In my experience it's better to cope with half-and-half pizza toppings when they arise, rather than coding as if they're already needed. Because when they are needed, you'll probably find the requirement is actually to put them on a 3-tier wedding cake, or a car.
Re: DRY is an over-rated programming principle?
#7In all fairness, the best programming principle is: just like with software licenses, know what to use and when.
Re: DRY is an over-rated programming principle?
#8Re: DRY is an over-rated programming principle?
#9Re: DRY is an over-rated programming principle?
#10left_toppings = ["beef"] right_toppings = [] make_pizza([left_toppings, right_toppings]) # this will be a very funny pizza Holy cow I was not expecting a none pizza with left beef reference in code form
Be prepared for laughter