Skip to main content
2 of 4
deleted 1 character in body
Doc Brown
  • 220.3k
  • 35
  • 410
  • 623

Robert C. Martin in his book "Clean Code" recommends heavily the use of functions with 0, 1 or 2 parameters at maximum, so at least there is one experienced book author who thinks code becomes cleaner by using this style (however, he is surely not the ultimative authority here, and his opinions are debatable).

Where Bob Martin is IMHO correct is that functions with 3 or more parameters might indicate a code smell. However, I do not think it would be a good idea to invent a new language for this:

  • if you really want to enforce such a rule throughout your code, you just need a style checker for an existing language, no need to invent a completely new language for this (for example, for C# something like 'fxcop' could probably be utilized).

  • there are sometimes real world scenarios where more than 2 parameters are needed for technical reasons (for example, when you need a 1:1 mapping to an existing API where you are bound to the usage of simple datatypes, and can't combine different parameters into one custom object)

Doc Brown
  • 220.3k
  • 35
  • 410
  • 623