Is it bad to have a lot of parameters?

Is it bad to have a lot of parameters?

You can define as many parameters as you may need, but too many of them will make your routine difficult to understand and maintain. Of course, you could use a structured variable as a workaround: putting all those variables in a single struct and passing it to the routine.

What is function parameter list?

The parameter list of a function describes the number and types of the arguments that the function accepts, and the number and types of the values it returns. The parameter list of a generic function is used to define the overall protocol of the generic function.

When to ignore a long list of parameters?

Long Parameter List 1 Signs and Symptoms. More than three or four parameters for a method. 2 Reasons for the Problem. A long list of parameters might happen after several types of algorithms are merged in a single method. 3 Treatment. Check what values are passed to parameters. 4 Payoff. More readable, shorter code. 5 When to Ignore.

Can a method be passed a long list of parameters?

Instead of a long list of parameters, a method can use the data of its own object. If the current object doesn’t contain all necessary data, another object (which will get the necessary data) can be passed as a method parameter. Check what values are passed to parameters.

When to replace a parameter with a method call?

If some of the arguments are just results of method calls of another object, use Replace Parameter with Method Call. This object can be placed in the field of its own class or passed as a method parameter.

When to use another object as a parameter?

If the current object doesn’t contain all necessary data, another object (which will get the necessary data) can be passed as a method parameter. Check what values are passed to parameters. If some of the arguments are just results of method calls of another object, use Replace Parameter with Method Call.