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

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Is this a coding horror? Pin
BubingaMan30-Aug-11 3:17
BubingaMan30-Aug-11 3:17 
GeneralRe: Is this a coding horror? Pin
ii_noname_ii30-Aug-11 3:37
ii_noname_ii30-Aug-11 3:37 
GeneralRe: Is this a coding horror? Pin
Stefan_Lang30-Aug-11 3:49
Stefan_Lang30-Aug-11 3:49 
GeneralRe: Is this a coding horror? Pin
IAbstract30-Aug-11 4:13
IAbstract30-Aug-11 4:13 
GeneralRe: Is this a coding horror? Pin
Schmuli30-Aug-11 23:10
Schmuli30-Aug-11 23:10 
GeneralRe: Is this a coding horror? Pin
IAbstract31-Aug-11 1:27
IAbstract31-Aug-11 1:27 
GeneralRe: Is this a coding horror? Pin
Jim (SS)30-Aug-11 6:06
Jim (SS)30-Aug-11 6:06 
GeneralRe: Is this a coding horror? Pin
Kenneth Kasajian30-Aug-11 9:10
Kenneth Kasajian30-Aug-11 9:10 
First, the advantage of terse code is that you can more of the code on the screen at a time. If that advantage outweighs others, such as possibly the next guy getting confused, maybe it's worth it. Maybe you're writing code on a 40 column x 20 row terminal like an Atari 800. This likely may not be the case.

The next issue is optimization. Does this code optimize better than the equivalent:

if ((user.Roles & userRole) != 0)
    inRoles.Add(roleName);
else
    outRoles.Add(roleName);


I bet the rewritten version isn't any less optimized.

Third, which one is easier to single-step through? Some debuggers only let you step through lines, not statements.

And finally, if you're doing this so that people will go, "wow, you can do that? that works? wow", then you're likely to be breaking the Principle of least astonishment.
ken@kasajian.com / www.kasajian.com

GeneralRe: Is this a coding horror? Pin
OriginalGriff30-Aug-11 9:19
mveOriginalGriff30-Aug-11 9:19 
GeneralRe: Is this a coding horror? Pin
Kenneth Kasajian30-Aug-11 19:13
Kenneth Kasajian30-Aug-11 19:13 
GeneralRe: Is this a coding horror? Pin
OriginalGriff30-Aug-11 21:43
mveOriginalGriff30-Aug-11 21:43 
GeneralRe: Is this a coding horror? Pin
BobJanova30-Aug-11 23:07
BobJanova30-Aug-11 23:07 
GeneralRe: Is this a coding horror? Pin
Tech Code Freak30-Aug-11 20:30
Tech Code Freak30-Aug-11 20:30 
GeneralRe: Is this a coding horror? Pin
Tom Chantler1-Sep-11 3:06
professionalTom Chantler1-Sep-11 3:06 
GeneralRe: Is this a coding horror? Pin
thoiness1-Sep-11 5:14
thoiness1-Sep-11 5:14 
GeneralTryParse - you should Try understanding!!! Pin
VallarasuS26-Aug-11 21:17
VallarasuS26-Aug-11 21:17 
JokeRe: TryParse - you should Try understanding!!! Pin
Manfred Rudolf Bihy27-Aug-11 23:22
professionalManfred Rudolf Bihy27-Aug-11 23:22 
JokeRe: TryParse - you should Try understanding!!! Pin
Chris Meech29-Aug-11 4:03
Chris Meech29-Aug-11 4:03 
GeneralRe: TryParse - you should Try understanding!!! Pin
Manfred Rudolf Bihy30-Aug-11 0:39
professionalManfred Rudolf Bihy30-Aug-11 0:39 
GeneralRe: TryParse - you should Try understanding!!! Pin
Shameel27-Aug-11 23:43
professionalShameel27-Aug-11 23:43 
GeneralRe: TryParse - you should Try understanding!!! Pin
Bernhard Hiller28-Aug-11 23:09
Bernhard Hiller28-Aug-11 23:09 
GeneralGoto vs if/esle PinPopular
Not Active26-Aug-11 9:24
mentorNot Active26-Aug-11 9:24 
GeneralRe: Goto vs if/esle Pin
ekolis29-Aug-11 3:43
ekolis29-Aug-11 3:43 
GeneralRe: Goto vs if/esle Pin
BobJanova30-Aug-11 2:44
BobJanova30-Aug-11 2:44 
GeneralRe: Goto vs if/esle Pin
AdamEcc30-Aug-11 3:10
AdamEcc30-Aug-11 3:10 

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.