Click here to Skip to main content
15,906,816 members

Survey Results

Are optional parameters for methods good or bad?   [Edit]

Survey period: 28 Feb 2005 to 6 Mar 2005

C++ has them, C# doesn't. Overall, what's your preference?

OptionVotes% 
Good84865.48
Bad28722.16
Undecided16012.36



 
GeneralA proposal that (I think) would make everyone happy Pin
Don Clugston6-Mar-05 15:51
Don Clugston6-Mar-05 15:51 
GeneralRe: A proposal that (I think) would make everyone happy Pin
Michael Flanakin10-Mar-05 11:25
Michael Flanakin10-Mar-05 11:25 
GeneralDepends on the language... Pin
Jeremy Falcon6-Mar-05 4:55
professionalJeremy Falcon6-Mar-05 4:55 
GeneralThere should be no parararmeters Pin
Anonymous3-Mar-05 18:00
Anonymous3-Mar-05 18:00 
GeneralDefaults promote bad design Pin
Peter Ritchie3-Mar-05 15:35
Peter Ritchie3-Mar-05 15:35 
Arguably, it also promotes laziness.

With a language that provides overloading, it's merely syntactic sugar. It goes against object-oriented ideals and is often confused with polymorphism--which it isn't. It's basically a hard-coded value, a define--something frowned-upon by C++ experts.

Anyone who argues against a switch statement in object-oriented programming should also argue against default parameters.

It could be useful for non-integral types; but C++ does not make that distinction, and makes its use potentially dangerous.

An interface (function interface in this conversation) is a contract between the interface and the consumer that must never be broken. In C++ It's easy to see when the contract is broken when you change the type of a parameter (most of the time); but not possible in all circumstances if the default value of a parameter is changed.

Sure, we're all guilty of being lazy and using default parameters, avoiding redesign or avoiding writing another overload. Default parameters should be put on the shelf with GOTO and multiple inheritance because they cause more problems then they solve: decreasing clarity and maintainability.



PeterRitchie.com
GeneralNone is best! Pin
Bob Stanneveld28-Feb-05 20:39
Bob Stanneveld28-Feb-05 20:39 
GeneralRe: None is best! Pin
netclectic28-Feb-05 23:38
netclectic28-Feb-05 23:38 
GeneralRe: None is best! Pin
Nemanja Trifunovic1-Mar-05 2:56
Nemanja Trifunovic1-Mar-05 2:56 
GeneralRe: None is best! Pin
tom_dx1-Mar-05 1:58
tom_dx1-Mar-05 1:58 
GeneralRe: None is best! Pin
Bob Stanneveld1-Mar-05 3:29
Bob Stanneveld1-Mar-05 3:29 
GeneralRe: None is best! Pin
Anonymous3-Mar-05 14:09
Anonymous3-Mar-05 14:09 
GeneralRe: None is best! Pin
tom_dx3-Mar-05 14:10
tom_dx3-Mar-05 14:10 
Generalpowerful feature Pin
Member 129322928-Feb-05 19:20
Member 129322928-Feb-05 19:20 
GeneralAn alternative! Pin
Eddie de Bear28-Feb-05 17:11
Eddie de Bear28-Feb-05 17:11 
GeneralRe: An alternative! Pin
Bob Stanneveld28-Feb-05 20:30
Bob Stanneveld28-Feb-05 20:30 
GeneralI hate them. They foul up generic code. Pin
Don Clugston28-Feb-05 13:40
Don Clugston28-Feb-05 13:40 
GeneralDepends Pin
Giancarlo Aguilera28-Feb-05 9:17
Giancarlo Aguilera28-Feb-05 9:17 
GeneralMissing classes in the model Pin
Daniel Turini28-Feb-05 8:17
Daniel Turini28-Feb-05 8:17 
GeneralOverload nitemare Pin
leppie27-Feb-05 19:57
leppie27-Feb-05 19:57 
GeneralRe: Overload nitemare Pin
WillemM27-Feb-05 20:01
WillemM27-Feb-05 20:01 
GeneralRe: Overload nitemare Pin
Corneliu Tusnea27-Feb-05 22:07
Corneliu Tusnea27-Feb-05 22:07 
GeneralRe: Overload nitemare Pin
WoR27-Feb-05 23:36
WoR27-Feb-05 23:36 
GeneralRe: Overload nitemare Pin
paulccc28-Feb-05 0:59
paulccc28-Feb-05 0:59 
GeneralRe: Overload nitemare Pin
Chris Meech28-Feb-05 1:46
Chris Meech28-Feb-05 1:46 
GeneralRe: Overload nitemare Pin
Blake Miller28-Feb-05 5:13
Blake Miller28-Feb-05 5:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.