Click here to Skip to main content
14,458,327 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: C# code survey Pin
Rob Philpott30-Oct-18 7:34
MemberRob Philpott30-Oct-18 7:34 
GeneralRe: C# code survey Pin
ScottM131-Oct-18 0:10
MemberScottM131-Oct-18 0:10 
GeneralRe: C# code survey Pin
Sander Rossel31-Oct-18 1:49
professionalSander Rossel31-Oct-18 1:49 
GeneralRe: C# code survey Pin
DerekT-P31-Oct-18 2:31
professionalDerekT-P31-Oct-18 2:31 
GeneralRe: C# code survey Pin
Super Lloyd31-Oct-18 7:38
MemberSuper Lloyd31-Oct-18 7:38 
GeneralRe: C# code survey Pin
DerekT-P31-Oct-18 9:34
professionalDerekT-P31-Oct-18 9:34 
GeneralRe: C# code survey Pin
Super Lloyd31-Oct-18 10:12
MemberSuper Lloyd31-Oct-18 10:12 
GeneralRe: C# code survey Pin
jhunley31-Oct-18 4:37
Memberjhunley31-Oct-18 4:37 
Nobody seems to have yet mentioned any other alternatives...one would be passing in a structure with 24 members as an initializer, although in C# that doesn't really eliminate the problem, since you'd have a similar problem with how to initialize the structure. Might be useful tho if you instantiated a lot of these objects with mostly the same parameters.

I would never condone instantiating a class without initializing all member data items, but if there are reasonable default values for them, I could see an initializer (or maybe even a few) that initialized all or most of them to default values, and only set one or two to non-default values. Don't ever want to leave values uninitialized, however.

Of course, there are those who would say that any object that needs this many initializers is poorly designed and should be refactored. It would be up to the author in each individual case to decide if this is feasible.

For my money, this makes a good case for a language feature I've been wanting ever since the days I worked with the ADA language - named parameter lists. Then you could offer default values for all parameters, and let the caller set only the ones (s)he wants to differ from the default values. Of course, you can emulate this now in C#, but it requires 2^n constructors. I've done it with three parameters (eight constructors), but of course it would be impractical with 24.
GeneralRe: C# code survey Pin
michaelakin31-Oct-18 5:08
Membermichaelakin31-Oct-18 5:08 
GeneralRe: C# code survey Pin
michaelakin31-Oct-18 5:08
Membermichaelakin31-Oct-18 5:08 
GeneralRe: C# code survey Pin
jhunley31-Oct-18 5:17
Memberjhunley31-Oct-18 5:17 
GeneralRe: C# code survey Pin
michaelakin31-Oct-18 5:29
Membermichaelakin31-Oct-18 5:29 
GeneralRe: C# code survey Pin
jhunley31-Oct-18 6:00
Memberjhunley31-Oct-18 6:00 
GeneralRe: C# code survey Pin
Bruce Patin31-Oct-18 4:44
MemberBruce Patin31-Oct-18 4:44 
GeneralRe: C# code survey Pin
michaelakin31-Oct-18 5:19
Membermichaelakin31-Oct-18 5:19 
AnswerRe: C# code survey Pin
Leonardo Pessoa31-Oct-18 7:43
MemberLeonardo Pessoa31-Oct-18 7:43 
GeneralRe: C# code survey Pin
Leng Vang31-Oct-18 9:06
MemberLeng Vang31-Oct-18 9:06 
GeneralRe: C# code survey Pin
Super Lloyd31-Oct-18 10:17
MemberSuper Lloyd31-Oct-18 10:17 
GeneralRe: C# code survey Pin
Roger House31-Oct-18 15:10
MemberRoger House31-Oct-18 15:10 
GeneralRe: C# code survey Pin
patbob1-Nov-18 6:29
Memberpatbob1-Nov-18 6:29 
GeneralI was sent this, and... Pin
OriginalGriff29-Oct-18 22:03
communityengineerOriginalGriff29-Oct-18 22:03 
GeneralRe: I was sent this, and... Pin
Chris Maunder30-Oct-18 4:09
cofounderChris Maunder30-Oct-18 4:09 
GeneralRe: I was sent this, and... Pin
OriginalGriff30-Oct-18 4:19
communityengineerOriginalGriff30-Oct-18 4:19 
GeneralRe: I was sent this, and... Pin
Member 798912230-Oct-18 4:43
MemberMember 798912230-Oct-18 4:43 
Generalif you are feeling smart today...! Pin
David Crow29-Oct-18 11:34
MemberDavid Crow29-Oct-18 11:34 

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.