Skip to main content
31 events
when toggle format what by license comment
Jul 24, 2022 at 19:05 comment added Roger House Alan Perlis once said that if you have written a function with 10 parameters, you have probably missed one.
Feb 7, 2019 at 18:58 answer added sonnyb timeline score: 0
Jun 18, 2018 at 15:31 comment added Mark Rosenblitt-Janssen Samurai Jack proved that there is NEVER any need for more than four parameters, except for certain meta-programs, like compilers.
Jan 15, 2018 at 17:56 comment added Eric Zhang I just wanted to point out that there are very legitimate libraries with 25-parameter constructors. In this case, it's actually quite necessary!
Nov 4, 2017 at 1:38 comment added maaartinus @Ominus What? Only 10 parameters? That's nothing, much more is needed. :D
Sep 27, 2017 at 17:50 comment added Reinstate Monica One practical consideration when designing your API is Java is limited to 255 parameters (minus one for every long or double typed parameter). I try to stay under 200 just to be safe.
Sep 27, 2017 at 17:23 answer added Billal BEGUERADJ timeline score: 0
S Mar 13, 2017 at 13:31 history suggested jchanger
Improved tags
Mar 13, 2017 at 11:34 review Suggested edits
S Mar 13, 2017 at 13:31
Sep 14, 2016 at 0:38 comment added Stack Exchange Broke The Law Yes, there are guidelines. One of the guidelines says at most three parameters. Another guideline says up to five. Another guideline says use 0 and use global variables to transfer data around. Another guideline says as many as necessary and definitely don't do what the previous guideline said.
Feb 9, 2016 at 0:03 comment added kevin cline Never add boolean switches to alter function behavior. Split the function instead. Break out the common behavior into new functions.
Mar 17, 2014 at 11:53 history protected gnat
Apr 24, 2012 at 19:26 answer added Chris Allen Lane timeline score: 3
Apr 19, 2012 at 15:26 vote accept Darth Egregious
Apr 19, 2012 at 14:38 answer added Leo timeline score: 18
Apr 19, 2012 at 5:30 comment added perp 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.
Apr 19, 2012 at 1:43 comment added Danny Varod @Ominus you should ask that in a question, not a comment. Also the answer is no.
Apr 19, 2012 at 1:40 comment added Danny Varod A non negative amount. If the amount is too big for comfort, consider using complex parameters, object fields/properties, optional parameters, overloads.
Apr 19, 2012 at 1:39 answer added James Anderson timeline score: 11
Apr 19, 2012 at 1:31 comment added Renato Dinhani I updated my answer with more details about the guidelines.
Apr 18, 2012 at 20:57 comment added chrisaycock Definitely don't follow the example of MPI_Sendrecv(), which takes 12 parameters!
Apr 18, 2012 at 20:42 answer added Michael Durrant timeline score: -1
Apr 18, 2012 at 20:31 comment added c_maker @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.
Apr 18, 2012 at 20:24 comment added Ominus A lot of people here saying that this isn't really the way to go with a on of parms. However what about object constructors. Taken an ORM with a class and its INIT method. I have had cases where i would need 10 or more params that have to be set to something that can't default well. I hate looking at the init function because its hard to work with and hard to remember. Is a constructor an OK edge case or is there a better way to do it?
Apr 18, 2012 at 20:08 history tweeted twitter.com/#!/StackProgrammer/status/192706130600927232
Apr 18, 2012 at 20:01 answer added Renato Dinhani timeline score: 55
Apr 18, 2012 at 18:59 answer added java_mouse timeline score: 32
Apr 18, 2012 at 18:25 answer added Evan Plaice timeline score: 5
Apr 18, 2012 at 18:09 answer added Michael K timeline score: 157
Apr 18, 2012 at 18:09 answer added Telastyn timeline score: 4
Apr 18, 2012 at 17:31 history asked Darth Egregious CC BY-SA 3.0