Click here to Skip to main content
15,894,180 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 
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 
Cose you can default them.
Eg:
<br />
public void SendOrder( string asset, Side side, double price, double size )<br />
{<br />
  SendOrder( asset, side, price, size, null, null )<br />
}<br />
public void SendOrder( string asset, Side side, double price, double size, string clientid, string allocationid )<br />
{<br />
}


Now, you want to call the first one in 99% of the cases.
You need the second method _only_ in one case.
1. Why do you need to define two methods?
2. Why would I make all the calls to the second method and drop null params all the time in?

Wouldn't it be nice if you would have:
public void SendOrder( string asset, Side side, double price, double size, string clientid = null, string allocationid =null ) ?

Look at how dbs are designed. You can always have "nullable" columns for the same reason. You might not need a specific parameter all the time. Why to do the overhead in all your calls to drop some null params just because in 1 case you need them?
Also why write proxy functions and fill code with crap just to reroute one call?

My 2 cents .. and 2 optional params Poke tongue | ;-P
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.