3 ms·
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 upd
by forrestthewoods 10y ago
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.
- weberc2 10y agoYou 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".