The Stack Overflow podcast is back! Listen to an interview with our new CEO.
    Tweeted twitter.com/StackProgrammer/status/782038438254153728
2 redundant tag removed from title
| link

Clean Code: Techniques for minimising number of function arguments

1
source | link

Clean Code: Techniques for minimising number of function arguments

In Clean Code, it is written that "the ideal number of arguments for a function is zero". The reasons why are explained and make sense. What I'm after is techniques to refactor methods with 4 or more arguments to solve this issue.

One way is to extract the arguments into a new class, but that would surely lead to an explosion of classes? And those classes are likely to end up with names that violate some of the naming rules (ending with "Data" or "Info" etc)?

Another technique is to make variables used by multiple functions a private member variable to avoid passing them, but that expands the scope of the variable, possibly such that it's open to functions that don't actually need it.

Just looking for ways to minimise function arguments, having accepted the reasons why it's a good idea to do so.