Functions with many parameters are hard to understand and to use, and should be avoided.

In some cases it may be possible to split the function into multiple smaller functions, each of which only requires a subset of parameters. Where this is not possible, consider passing the parameters as an object literal and accessing them as properties of that literal.

In the following example, function sendRecord has nine parameters. Such a function is hard to use, since the user has to remember in which order to pass the arguments.

The function should be refactored to use a parameter object instead, with each parameter of the old function corresponding to a property of the object as in the following code. Of course, any calls to the function have to be updated accordingly.

  • Cunningham & Cunningham, Inc: Code Smell: Too Many Parameters.