Click here to Skip to main content
15,920,630 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: Variation of bad boolean check. Pin
Pete O'Hanlon19-Mar-07 4:08
mvePete O'Hanlon19-Mar-07 4:08 
GeneralRe: Variation of bad boolean check. Pin
Hal Angseesing28-Mar-07 6:19
professionalHal Angseesing28-Mar-07 6:19 
GeneralRe: Variation of bad boolean check. Pin
kakan19-Mar-07 23:01
professionalkakan19-Mar-07 23:01 
GeneralRe: Variation of bad boolean check. Pin
jhwurmbach21-Mar-07 4:00
jhwurmbach21-Mar-07 4:00 
GeneralRe: Variation of bad boolean check. Pin
kakan21-Mar-07 5:04
professionalkakan21-Mar-07 5:04 
GeneralRe: Variation of bad boolean check. Pin
Pete O'Hanlon21-Mar-07 5:28
mvePete O'Hanlon21-Mar-07 5:28 
GeneralRe: Variation of bad boolean check. Pin
kakan21-Mar-07 20:04
professionalkakan21-Mar-07 20:04 
GeneralRe: Variation of bad boolean check. Pin
Emilio Garavaglia22-Mar-07 22:14
Emilio Garavaglia22-Mar-07 22:14 
Well, may be it's not the best way, but there could be good resons:

1) instance.Variable is a generic class you don't know the type, but you kow it supports bool operator==(int). Assuming that an implicit conversion to bool will do the same is not obvious. (And such a conversion may be even not existent)

2) if instance.Variable is an int, assigning an int to a bool gives a warning. That code eliminates it
2a) But there is a int-to-bool native converter: the !! pseudo-oprerator
bool isValue(!!instance.Variable);




2 bugs found.
> recompile ...
65534 bugs found.
D'Oh! | :doh:

GeneralRe: Variation of bad boolean check. Pin
Pete O'Hanlon23-Mar-07 0:16
mvePete O'Hanlon23-Mar-07 0:16 
GeneralASP.NET Server-side text change notification? Pin
varnk15-Mar-07 3:04
varnk15-Mar-07 3:04 
GeneralRe: ASP.NET Server-side text change notification? Pin
N a v a n e e t h19-Mar-07 22:44
N a v a n e e t h19-Mar-07 22:44 
GeneralWhat you say is what you code Pin
Rage14-Mar-07 7:47
professionalRage14-Mar-07 7:47 
GeneralRe: What you say is what you code Pin
PIEBALDconsult14-Mar-07 10:38
mvePIEBALDconsult14-Mar-07 10:38 
GeneralRe: What you say is what you code Pin
Captain See Sharp14-Mar-07 13:10
Captain See Sharp14-Mar-07 13:10 
GeneralRe: What you say is what you code Pin
Dan Neely15-Mar-07 2:23
Dan Neely15-Mar-07 2:23 
GeneralRe: What you say is what you code Pin
Russell Jones16-Mar-07 5:19
Russell Jones16-Mar-07 5:19 
GeneralRe: What you say is what you code Pin
Ed.Poore16-Mar-07 6:27
Ed.Poore16-Mar-07 6:27 
GeneralRe: What you say is what you code Pin
Captain See Sharp16-Mar-07 7:18
Captain See Sharp16-Mar-07 7:18 
GeneralRe: What you say is what you code Pin
Russell Jones16-Mar-07 10:54
Russell Jones16-Mar-07 10:54 
GeneralRe: What you say is what you code Pin
Muammar©16-Mar-07 9:05
Muammar©16-Mar-07 9:05 
GeneralRe: What you say is what you code Pin
John R. Shaw14-Mar-07 16:59
John R. Shaw14-Mar-07 16:59 
GeneralNo QA for language in GUI [modified] Pin
Marcus J. Smith14-Mar-07 6:27
professionalMarcus J. Smith14-Mar-07 6:27 
GeneralRe: No QA for language in GUI Pin
Pete O'Hanlon16-Mar-07 1:18
mvePete O'Hanlon16-Mar-07 1:18 
GeneralRe: No QA for language in GUI Pin
Marcus J. Smith16-Mar-07 2:23
professionalMarcus J. Smith16-Mar-07 2:23 
GeneralRe: No QA for language in GUI Pin
Pete O'Hanlon16-Mar-07 3:48
mvePete O'Hanlon16-Mar-07 3:48 

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.