Click here to Skip to main content
15,892,643 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
Colborne_Greg19-May-14 9:55
Colborne_Greg19-May-14 9:55 
GeneralRe: Best Practice Question - How do you prefer to pass a bunch of options to a function? Pin
Colborne_Greg19-May-14 8:51
Colborne_Greg19-May-14 8:51 
GeneralRe: Best Practice Question - How do you prefer to pass a bunch of options to a function? Pin
PIEBALDconsult18-May-14 18:12
mvePIEBALDconsult18-May-14 18:12 
GeneralRe: Best Practice Question - How do you prefer to pass a bunch of options to a function? PinPopular
_Maxxx_18-May-14 19:02
professional_Maxxx_18-May-14 19:02 
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 
I think it's important that there's an easy way to find which options are defined. I've had issues with Javascript libraries that take an object as a parameter, and expect you to put the right properties in there (the XMLHttpRequest AJAX handler does this iirc). In a statically typed language like C# or Java (or even C, Delphi, C++ etc), it makes sense to use a struct or class (using those words in their C# meaning) for groups of parameters with values, and a flagwise enum for those without. If you don't have enums then the old school approach of constants set to the appropriate bit values and using | to combine them is fine too.

The grouping is important, it shouldn't just be public struct StuffUsedByThisFunction, it should have some semantic meaning even outwith the context of the function call.

In dynamic languages the convention seems to be dictionaries with lax validation. I agree that this is often unhelpful, but it's encouraged by the object model in those languages which doesn't really do static declaration of valid members. I've not really worked in those languages enough to have developed a good solution, though.
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 
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 Pin
Duncan Edwards Jones18-May-14 5:19
professionalDuncan Edwards Jones18-May-14 5:19 
GeneralRe: Electronaggedon Pin
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 

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.