Click here to Skip to main content
15,919,479 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: Logical thinking could get very complicated Pin
OriginalGriff12-Apr-13 23:16
mveOriginalGriff12-Apr-13 23:16 
GeneralRe: Logical thinking could get very complicated Pin
ENOTTY13-Apr-13 20:40
ENOTTY13-Apr-13 20:40 
GeneralRe: Logical thinking could get very complicated Pin
Tomz_KV15-Apr-13 1:40
Tomz_KV15-Apr-13 1:40 
JokeRe: Logical thinking could get very complicated Pin
Bernhard Hiller14-Apr-13 22:01
Bernhard Hiller14-Apr-13 22:01 
GeneralRe: Logical thinking could get very complicated Pin
Tomz_KV15-Apr-13 1:42
Tomz_KV15-Apr-13 1:42 
GeneralRe: Logical thinking could get very complicated Pin
ENOTTY15-Apr-13 4:25
ENOTTY15-Apr-13 4:25 
GeneralRe: Logical thinking could get very complicated Pin
YDaoust15-Apr-13 20:27
YDaoust15-Apr-13 20:27 
GeneralRe: Logical thinking could get very complicated Pin
Tomz_KV16-Apr-13 1:34
Tomz_KV16-Apr-13 1:34 
GeneralUnambiguously Ambiguous Pin
AspDotNetDev10-Apr-13 15:53
protectorAspDotNetDev10-Apr-13 15:53 
GeneralRe: Unambiguously Ambiguous Pin
Brisingr Aerowing10-Apr-13 17:13
professionalBrisingr Aerowing10-Apr-13 17:13 
GeneralRe: Unambiguously Ambiguous Pin
Wendelius10-Apr-13 18:37
mentorWendelius10-Apr-13 18:37 
GeneralRe: Unambiguously Ambiguous Pin
Jim Meadors10-Apr-13 19:11
Jim Meadors10-Apr-13 19:11 
GeneralRe: Unambiguously Ambiguous Pin
dan!sh 10-Apr-13 22:07
professional dan!sh 10-Apr-13 22:07 
GeneralLet's "switch" to Something Else Pin
Tom Delany2-Apr-13 9:31
Tom Delany2-Apr-13 9:31 
GeneralRe: Let's "switch" to Something Else Pin
Brisingr Aerowing2-Apr-13 12:13
professionalBrisingr Aerowing2-Apr-13 12:13 
GeneralRe: Let's "switch" to Something Else Pin
Freak302-Apr-13 21:44
Freak302-Apr-13 21:44 
GeneralRe: Let's "switch" to Something Else Pin
Bernhard Hiller2-Apr-13 22:29
Bernhard Hiller2-Apr-13 22:29 
GeneralRe: Let's "switch" to Something Else Pin
PIEBALDconsult3-Apr-13 5:13
mvePIEBALDconsult3-Apr-13 5:13 
GeneralRe: Let's "switch" to Something Else Pin
H.Brydon13-Apr-13 14:22
professionalH.Brydon13-Apr-13 14:22 
GeneralRe: Let's "switch" to Something Else Pin
PIEBALDconsult13-Apr-13 19:39
mvePIEBALDconsult13-Apr-13 19:39 
GeneralRe: Let's "switch" to Something Else Pin
H.Brydon14-Apr-13 9:07
professionalH.Brydon14-Apr-13 9:07 
GeneralRe: Let's "switch" to Something Else Pin
OriginalGriff3-Apr-13 6:25
mveOriginalGriff3-Apr-13 6:25 
It's ugly, yes.

But it also has the potential to be fast. By loading the three characters and one space into a machine word, it is a single machine instruction to compare each value, and if the compiler spots that - and it damn well should - then it can use a machine-word look up table and index into a machine-word jump table. And you can't get much faster than that!

If this is in time-critical code, then it could be justified. Provided it was well commented. If it's in user input handling, then the author needs to meet Mr Firing Squad for being too "clever". Laugh | :laugh:
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

GeneralRe: Let's "switch" to Something Else Pin
Tom Delany3-Apr-13 8:02
Tom Delany3-Apr-13 8:02 
GeneralRe: Let's "switch" to Something Else Pin
OriginalGriff3-Apr-13 8:14
mveOriginalGriff3-Apr-13 8:14 
GeneralRe: Let's "switch" to Something Else Pin
BobJanova3-Apr-13 23:27
BobJanova3-Apr-13 23:27 

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.