Click here to Skip to main content
15,895,746 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Best Practice Question - How do you prefer to pass a bunch of options to a function? Pin
Jörgen Andersson18-May-14 20:30
professionalJörgen Andersson18-May-14 20:30 
GeneralRe: Best Practice Question - How do you prefer to pass a bunch of options to a function? Pin
CPallini18-May-14 21:43
mveCPallini18-May-14 21:43 
GeneralRe: Best Practice Question - How do you prefer to pass a bunch of options to a function? Pin
kalberts18-May-14 22:33
kalberts18-May-14 22:33 
GeneralRe: Best Practice Question - How do you prefer to pass a bunch of options to a function? Pin
BobJanova19-May-14 1:13
BobJanova19-May-14 1:13 
GeneralRe: Best Practice Question - How do you prefer to pass a bunch of options to a function? Pin
Tony Moffatt19-May-14 1:36
Tony Moffatt19-May-14 1:36 
GeneralRe: Best Practice Question - How do you prefer to pass a bunch of options to a function? Pin
BobJanova19-May-14 6:58
BobJanova19-May-14 6:58 
JokeRe: Best Practice Question - How do you prefer to pass a bunch of options to a function? Pin
Kirk 1038982119-May-14 3:51
Kirk 1038982119-May-14 3:51 
GeneralRe: Best Practice Question - How do you prefer to pass a bunch of options to a function? Pin
patbob19-May-14 5:57
patbob19-May-14 5:57 
If the function has "too many" arguments, accept that it's ugly and live with it. Putting them in a struct is just hiding the ugliness and moving the complexity elsewhere, possibly remote from the function call itself. In my mind, it just makes for extra work to understand and maintain.

The optional argument example is a perfect time to use an overload. That way you have a place to document the unique behavior of that variation of the function, and have documented for the next developer which arguments need to be specified as a set.

The struct solution isn't a bad way to hide the problem, although a polymorphic class might be better depending on the needs.
We can program with only 1's, but if all you've got are zeros, you've got nothing.

GeneralRe: Best Practice Question - How do you prefer to pass a bunch of options to a function? Pin
RafagaX19-May-14 9:35
professionalRafagaX19-May-14 9:35 
GeneralRe: Best Practice Question - How do you prefer to pass a bunch of options to a function? Pin
User 483504720-May-14 3:51
User 483504720-May-14 3:51 
GeneralElectronaggedon Pin
#realJSOP18-May-14 4:44
mve#realJSOP18-May-14 4:44 
GeneralRe: Electronaggedon PinPopular
Duncan Edwards Jones18-May-14 5:19
professionalDuncan Edwards Jones18-May-14 5:19 
GeneralRe: Electronaggedon PinPopular
Paul M Watt18-May-14 6:17
mentorPaul M Watt18-May-14 6:17 
GeneralRe: Electronaggedon Pin
Rage18-May-14 22:25
professionalRage18-May-14 22:25 
GeneralRe: Electronaggedon Pin
AlphaDeltaTheta18-May-14 6:53
AlphaDeltaTheta18-May-14 6:53 
GeneralRe: Electronaggedon Pin
#realJSOP18-May-14 7:45
mve#realJSOP18-May-14 7:45 
GeneralRe: Electronaggedon Pin
Duncan Edwards Jones18-May-14 8:11
professionalDuncan Edwards Jones18-May-14 8:11 
GeneralRe: Electronaggedon Pin
#realJSOP18-May-14 10:36
mve#realJSOP18-May-14 10:36 
GeneralRe: Electronaggedon Pin
Gary Wheeler19-May-14 0:50
Gary Wheeler19-May-14 0:50 
GeneralRe: Electronaggedon Pin
#realJSOP19-May-14 5:40
mve#realJSOP19-May-14 5:40 
GeneralRe: Electronaggedon Pin
Roger Wright19-May-14 9:01
professionalRoger Wright19-May-14 9:01 
GeneralSunday Sermon PinPopular
Marc Clifton18-May-14 4:28
mvaMarc Clifton18-May-14 4:28 
GeneralRe: Sunday Sermon Pin
Gary Wheeler19-May-14 0:21
Gary Wheeler19-May-14 0:21 
GeneralRe: Sunday Sermon Pin
908236519-May-14 0:46
908236519-May-14 0:46 
GeneralRe: Sunday Sermon Pin
Kirk 1038982119-May-14 4:04
Kirk 1038982119-May-14 4:04 

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.