Timeline for Named arguments (parameters) as a readability aid
Current License: CC BY-SA 2.5
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Feb 28, 2011 at 22:48 | comment | added | btilly | @scott-whitlock: Do we actually disagree? We agree on what is best in C#. We both know what Clean Code says. My point was that it is important to understand why it is good, so that you know when the advice does or does not fit a different environment. | |
| Feb 28, 2011 at 20:06 | comment | added | Scott Whitlock | @btilly - as Ian pointed out, Clean Code clearly tells you not to have functions with more than 2 or 3 parameters. To be fair, it was dealing with Java, which is statically typed. The OP is also asking about C#, which is statically typed. I would still prefer to use function overloads and/or different precisely named function names than a long list of parameters. | |
| Feb 28, 2011 at 18:40 | comment | added | btilly | @scott-whitlock: Option 1 - create an object, set x properties, call a method once with your object. Option 2 - call a method with x named parameters. Which is better depends on your language. In a dynamically typed language, option 1 requires significantly more boiler-plate with no gain, and so is worse. In a statically typed language you still add the boilerplate, but tests for incorrectly named keys get to be done at compile time rather than run time. Therefore option 1 is better in C#, but option 2 is a clear win in Python. | |
| Feb 28, 2011 at 18:25 | comment | added | Scott Whitlock | @apoorv020 - if I had enough parameters to a method call that 2^x became significant, I'd make a new class to hold the parameter values, and just pass one parameter. | |
| Feb 28, 2011 at 14:34 | comment | added | apoorv020 | If you have x choices, will you make 2^x frontends? | |
| Feb 28, 2011 at 12:41 | history | answered | Scott Whitlock | CC BY-SA 2.5 |