Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

14
  • 6
    @Ominus: The idea is that you want to keep your classes focused. Focused classes usually do not have as many dependencies/attributes therefore you'd have less parameters to the constructor. Some buzz word people throw in at this point is high cohesion and single responsibility principle. If you feel that these are not violated and still need lots of params, consider using the Builder pattern. Commented Apr 18, 2012 at 20:31
  • 4
    Definitely don't follow the example of MPI_Sendrecv(), which takes 12 parameters! Commented Apr 18, 2012 at 20:57
  • 16
    The project I'm currently working on uses a certain framework, in which methods with 10+ parameters is commonplace. I'm calling one particular method with 27 parameters in a couple of places. Every time I see it I die a little inside. Commented Apr 19, 2012 at 5:30
  • 5
    Never add boolean switches to alter function behavior. Split the function instead. Break out the common behavior into new functions. Commented Feb 9, 2016 at 0:03
  • 4
    @Ominus What? Only 10 parameters? That's nothing, much more is needed. :D Commented Nov 4, 2017 at 1:38