Click here to Skip to main content
15,903,033 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: Straight from the horse's mouth PinPopular
CDP180213-Feb-12 0:03
CDP180213-Feb-12 0:03 
GeneralRe: Straight from the horse's mouth Pin
BobJanova13-Feb-12 3:45
BobJanova13-Feb-12 3:45 
GeneralRe: Straight from the horse's mouth Pin
Rob Grainger13-Feb-12 4:35
Rob Grainger13-Feb-12 4:35 
GeneralRe: Straight from the horse's mouth Pin
Frank Peelo14-Feb-12 0:49
Frank Peelo14-Feb-12 0:49 
GeneralRe: Straight from the horse's mouth Pin
Rob Grainger13-Feb-12 4:39
Rob Grainger13-Feb-12 4:39 
GeneralRe: Straight from the horse's mouth Pin
Dan Neely13-Feb-12 17:31
Dan Neely13-Feb-12 17:31 
GeneralRe: Straight from the horse's mouth Pin
Marc Greiner at home14-Feb-12 4:58
Marc Greiner at home14-Feb-12 4:58 
GeneralRe: Straight from the horse's mouth Pin
CDP180214-Feb-12 5:36
CDP180214-Feb-12 5:36 
In this case it's probably not worth getting angry over. Look what the compiler made out of this little test with a false condition:

            test = (1 == 0) ? true : false;
00000037  xor         edx,edx 
00000039  mov         dword ptr [ebp-40h],edx


It even pulled the old XOR trick out of the hat to set EDX to 0 Smile | :) It effectively realized that the condition will always be false and simply copied 0 into the variable.

Seriously, coding practices (good or bad, old or new) may become problematic when they are used because somebody said so or because they have always been used. Good practices and rules are not a good substitute for knowing (or being able to verify) what the compiler will make of your code. I had the dubious pleasure of working in a 'best practices' team recently and do not think very much about their religious belief in their rules and that nothing can go wrong as long as they firmly hold onto them. The gray mass in their heads is not just there to keep their ears apart Smile | :)
I'm invincible, I can't be vinced



GeneralRe: Straight from the horse's mouth Pin
Rob Grainger14-Feb-12 8:53
Rob Grainger14-Feb-12 8:53 
GeneralRe: Straight from the horse's mouth Pin
GibbleCH13-Feb-12 6:16
GibbleCH13-Feb-12 6:16 
GeneralRe: Straight from the horse's mouth Pin
Jeremy Hutchinson14-Feb-12 1:30
professionalJeremy Hutchinson14-Feb-12 1:30 
GeneralRe: Straight from the horse's mouth Pin
Vladimir Svyatski13-Feb-12 20:21
professionalVladimir Svyatski13-Feb-12 20:21 
GeneralRe: Straight from the horse's mouth Pin
Fran Porretto14-Feb-12 1:06
Fran Porretto14-Feb-12 1:06 
GeneralRe: Straight from the horse's mouth Pin
User 483504714-Feb-12 3:13
User 483504714-Feb-12 3:13 
GeneralRe: Straight from the horse's mouth Pin
BrainiacV14-Feb-12 3:58
BrainiacV14-Feb-12 3:58 
GeneralRe: Straight from the horse's mouth Pin
Massimo Perrone14-Feb-12 5:37
Massimo Perrone14-Feb-12 5:37 
GeneralRe: Straight from the horse's mouth Pin
Zan Lynx14-Feb-12 7:00
Zan Lynx14-Feb-12 7:00 
GeneralRe: Straight from the horse's mouth Pin
AspDotNetDev14-Feb-12 7:33
protectorAspDotNetDev14-Feb-12 7:33 
GeneralRe: Straight from the horse's mouth Pin
  Forogar  14-Feb-12 7:49
professional  Forogar  14-Feb-12 7:49 
GeneralRe: Straight from the horse's mouth Pin
KP Lee14-Feb-12 12:51
KP Lee14-Feb-12 12:51 
GeneralRe: Straight from the horse's mouth Pin
Patrick Harris19-Feb-12 19:21
Patrick Harris19-Feb-12 19:21 
GeneralRe: Straight from the horse's mouth Pin
JackDingler14-Feb-12 8:31
JackDingler14-Feb-12 8:31 
GeneralRe: Straight from the horse's mouth Pin
Rob Grainger14-Feb-12 8:55
Rob Grainger14-Feb-12 8:55 
GeneralRe: Straight from the horse's mouth Pin
JackDingler14-Feb-12 9:02
JackDingler14-Feb-12 9:02 
GeneralRe: Straight from the horse's mouth Pin
patbob14-Feb-12 11:43
patbob14-Feb-12 11:43 

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.