For your consideration
-
switch (es) { case CS\_DISENABLED: return ::CreateSolidBrush(brRed); break; case CS\_ENABLED: return ::GetSysColorBrush(COLOR\_WINDOW); break; case CS\_UNDEF: return ::CreateSolidBrush(brRed); break; default: return ::CreateSolidBrush(brRed); break; }
What's wrong here? I'll wait.
Software Zen:
delete this;
-
switch (es) { case CS\_DISENABLED: return ::CreateSolidBrush(brRed); break; case CS\_ENABLED: return ::GetSysColorBrush(COLOR\_WINDOW); break; case CS\_UNDEF: return ::CreateSolidBrush(brRed); break; default: return ::CreateSolidBrush(brRed); break; }
What's wrong here? I'll wait.
Software Zen:
delete this;
-
- none of the break statements are ever hit 2) default does not require nor need break statement 3) DISENABLED is a very odd word. those are all I got right now. :-D
Not to mention that it could be written as:
return (es == CS_ENABLED)?::GetSysColorBrush(COLOR_WINDOW) : ::CreateSolidBrush(brRed);
I woke up today with a bad case of one-line syndrome :)
Mircea
-
- none of the break statements are ever hit 2) default does not require nor need break statement 3) DISENABLED is a very odd word. those are all I got right now. :-D
Your #3 was the first thing I noticed, followed by #1. I think #2 is a matter of personal taste, as that works only when the
default:
case is the last one in theswitch
statement. FWIW, "disenabled" grates on my nerves only slightly less than the British word "orientate". I'm a third-generation 'Murican descended from German immigrants, and I use "orient" as the verb.Software Zen:
delete this;
-
Not to mention that it could be written as:
return (es == CS_ENABLED)?::GetSysColorBrush(COLOR_WINDOW) : ::CreateSolidBrush(brRed);
I woke up today with a bad case of one-line syndrome :)
Mircea
Mircea Neacsu wrote:
a bad case of one-line syndrome
This is one case where I actually like one-line solutions, especially using the conditional operator. I have a prejudice against using it in any case that takes more than a single line, or at worst something like this:
value = condition ?
true-value :
false-value;Anything more involved than that, and I want it expressed as a complete
if
statement.Software Zen:
delete this;
-
Your #3 was the first thing I noticed, followed by #1. I think #2 is a matter of personal taste, as that works only when the
default:
case is the last one in theswitch
statement. FWIW, "disenabled" grates on my nerves only slightly less than the British word "orientate". I'm a third-generation 'Murican descended from German immigrants, and I use "orient" as the verb.Software Zen:
delete this;
To the rest of the world (who actually speak English ;) ), the Orient is a (somewhat dated) way to refer to the Far East. It's where oriental is derived.
"If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.