3 ms·
> Copypasta tends to accumulate minor differences and figuring out if those minor differences matters can become very time consuming. The DRY version of this i
by corrral 4y ago
> Copypasta tends to accumulate minor differences and figuring out if those minor differences matters can become very time consuming.
The DRY version of this is functions/constructors/methods that take a stupid number of parameters, many with unclear purposes.
- skrtskrt 4y agoAll the libraries I love and use the most have tons of parameters but they are really well documented including their parameters' interactions with each other.
- corrral 4y agoI don't mean well-considered and documented libraries, I mean the thing where someone goes to DRY up a codebase and keeps thinking "oh, if I just add a parameter this function can also handle this one-off case over here..." over, and over, and over, until you've got this function with a name that makes it look straightforward but for some reason it wants three strings, two of which should actually be nulled in most cases (and god help you if you fill in a value when you don't need them), an integer for unclear reasons but it's the same value in every call you can find, and half a dozen booleans that you'll have to go read the source to figure out, because some of them do more than the variable name in the signature implies. Good intentions at every step, but a Frankenstein's monster of a function (or entire class, sometimes) in the end It's the DRY equivalent of having 20 slightly-different copypastes all over a codebase.
- skrtskrt 4y agoAh yes :) The Django monolith I worked in for some time was like this - 30, 30, 40 parameters on the methods to handle completing a purchase.
- Jtsummers 4y agoIf it's unclear, then it's poor code or poor documentation or both. Sane developers will provide a way to obtain default or common configurations rather than forcing you to figure out the 100 different tunable options.
- lamontcg 4y agoIt isn't one sane developer. It is the aggregation of a dozen different developers each adding a knob to close a ticket/bug over the course of maybe 10 years.
- lamontcg 4y agoThe DRY version of this is base classes with subclasses that have crazy protected interfaces that violate Liskov all over the place. I'd rather debug code spaghetti by rearranging copypasta to sort out the simple deltas than try to unwind LSP-violating inheritance spaghetti.