Click here to Skip to main content
15,861,172 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.

 
GeneralSwitch boolean.... (reinventing if, unnecessarily) Pin
Rob Grainger25-Jun-15 5:25
Rob Grainger25-Jun-15 5:25 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
Jeremy Falcon25-Jun-15 5:42
professionalJeremy Falcon25-Jun-15 5:42 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
Freak3025-Jun-15 21:32
Freak3025-Jun-15 21:32 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
Jeremy Falcon26-Jun-15 3:23
professionalJeremy Falcon26-Jun-15 3:23 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
Bruce Patin26-Jun-15 6:16
Bruce Patin26-Jun-15 6:16 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
jibalt26-Jun-15 9:53
jibalt26-Jun-15 9:53 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
TheGreatAndPowerfulOz30-Jun-15 9:15
TheGreatAndPowerfulOz30-Jun-15 9:15 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
DSewhuk30-Jun-15 11:02
DSewhuk30-Jun-15 11:02 
If they had a default: case then I could almost see a reason. Consider the case if the bool was neither true or false. For most x86 C's there are 254 other trues and 65534 other trues on the DSP I code. I remember some very picky standards about what to do with unexpected values for space computing. Pesky alpha/beta/gamma particles flipping RAM cells around and the like.

I have fixed my share of mixed boolean true logics gone bad. Is it a one, -1 or non-zero?
If true == mySupposedBool can be very tricky to find in C when mySupposedBool = -1 from some other language interface.

At least false seems to always == 0.

-----
I love standards, there is so many to choose from!
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
Daniel Pfeffer30-Jun-15 18:08
professionalDaniel Pfeffer30-Jun-15 18:08 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
ZurdoDev25-Jun-15 6:00
professionalZurdoDev25-Jun-15 6:00 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
Silvabolt25-Jun-15 6:57
Silvabolt25-Jun-15 6:57 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
Rob Grainger25-Jun-15 9:04
Rob Grainger25-Jun-15 9:04 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
DJ van Wyk25-Jun-15 19:55
professionalDJ van Wyk25-Jun-15 19:55 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
Kirk 1038982126-Jun-15 3:22
Kirk 1038982126-Jun-15 3:22 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
Bruce Patin26-Jun-15 6:26
Bruce Patin26-Jun-15 6:26 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
cramotowski27-Jun-15 8:40
cramotowski27-Jun-15 8:40 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
phil.o25-Jun-15 10:23
professionalphil.o25-Jun-15 10:23 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
kmoorevs25-Jun-15 10:59
kmoorevs25-Jun-15 10:59 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
Sander Rossel25-Jun-15 20:32
professionalSander Rossel25-Jun-15 20:32 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
Simon O'Riordan from UK25-Jun-15 22:09
Simon O'Riordan from UK25-Jun-15 22:09 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
ScottM125-Jun-15 22:32
ScottM125-Jun-15 22:32 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
Eddy Vluggen25-Jun-15 23:28
professionalEddy Vluggen25-Jun-15 23:28 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
Simon O'Riordan from UK25-Jun-15 23:47
Simon O'Riordan from UK25-Jun-15 23:47 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
Eddy Vluggen26-Jun-15 0:09
professionalEddy Vluggen26-Jun-15 0:09 
GeneralRe: Switch boolean.... (reinventing if, unnecessarily) Pin
Simon O'Riordan from UK26-Jun-15 0:49
Simon O'Riordan from UK26-Jun-15 0:49 

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.