How many parameters in C# method are acceptable?

There is no general consensus and it depends on who you ask.

In general - the moment readability suffers, there are too many...

Bob Martin says the ideal number of parameters is 0 and that 3 is stretching it.

32 parameters is a massive code smell. It means the class has way too many responsibilities and needs to be refactored. Even applying a parameter object refactoring sounds to me like it would hide a bad design rather than solve the issue.

From Clean Code Tip of the Week #10:

Functions should have a small number of arguments. No argument is best, followed by one, two, and three. More than three is very questionable and should be avoided with prejudice.


Hmmm 32 parameters is way too much. There are as many rules as people i guess. However, common sense dictates that more than 6 becomes unwieldy.

When you have so many parameters it's always better to pass an object as a single parameter and have the parameters as properties, at least is easier to read.


I believe that a common feeling from the developer community is about 5 or 6 parameters maximum. The times that I've seen methods like yours, it is someone doing something like "SaveCustomer" and pass every field instead of passing a customer object.

Tags:

C#