Skip to main content
1 of 3
Michael K
  • 15.7k
  • 10
  • 65
  • 95

I've never seen a guideline, but in my experience a function that takes more than three or four parameters smells like one of two problems:

  1. The function is doing too much. It should be split into several smaller functions, each which have a smaller parameter set.
  2. There is another object hiding in there. You may need to create another object or data structure that includes these parameters. See this article on the Parameter Object pattern for more information.

It's difficult to tell what you're looking at without more information. Chances are the refactoring you need to do is split the function into smaller functions which are called from the parent depending on those flags that are currently being passed to the function.

Michael K
  • 15.7k
  • 10
  • 65
  • 95