News for hackers. Stuff that matters.
Re:Prefer duplication over the wrong abstraction by forrestthewoods on Saturday July 09, 2016 @12:11PM (#12061938)
Man I dunno. This is so tough.

On one hand, absolutely. Stacking params on params is a recipe for disaster. But often times with duplication you do need to update the duplicates. Which means you wind up with 6 pieces of code all similar but slightly different such that it fails in increasingly nuanced and edge casey ways.

No silver bullet unfortunately.

Re:Prefer duplication over the wrong abstraction by weberc2 on Saturday July 09, 2016 @01:17PM (#12062309)
You don't have to choose. If you have a function* with excessive arguments, it has too many responsibilities. Identify the responsibilities and make a function for each. Then replace the call sites of the original function with only the new functions that are appropriate for that use case. If you find that the same N new functions are repeatedly called in the same places, you can pull those out into a new function as well. It's all very simple, though learning to decompose responsibilities correctly takes practice.

* For sanity's sake, I'm just going to say "function" in place of "abstraction".