Click here to Skip to main content
15,889,335 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: How to test equality Pin
supercat930-Oct-09 9:26
supercat930-Oct-09 9:26 
GeneralRe: How to test equality Pin
Richard MacCutchan31-Oct-09 0:06
mveRichard MacCutchan31-Oct-09 0:06 
GeneralRe: How to test equality Pin
OriginalGriff31-Oct-09 0:51
mveOriginalGriff31-Oct-09 0:51 
GeneralRe: How to test equality Pin
supercat91-Nov-09 13:47
supercat91-Nov-09 13:47 
GeneralRe: How to test equality Pin
PJ Arends1-Nov-09 7:39
professionalPJ Arends1-Nov-09 7:39 
GeneralRe: How to test equality Pin
supercat91-Nov-09 13:27
supercat91-Nov-09 13:27 
GeneralRe: How to test equality Pin
Luc Pattyn1-Nov-09 13:33
sitebuilderLuc Pattyn1-Nov-09 13:33 
GeneralRe: How to test equality Pin
supercat91-Nov-09 14:45
supercat91-Nov-09 14:45 
Luc Pattyn wrote:
Furthermore I'm all in favor of using named constants for these kinds of tests, so the code becomes self-documenting.


I like named constants too, but many of the same issues remain. If I have a test:
if ((somevariable & SOMEIDENTIFIER) == SOMEIDENTIFIER) I have to worry about whether the two "SOMEIDENTIFIER"s are the same. If the identifiers are the same and the value gets changed (but remains a power of two) things will be fine, but if the code is copied/pasted and then modified to use a different identifier, an imperfect patch job could cause all sorts of problems.
GeneralRe: How to test equality Pin
Luc Pattyn1-Nov-09 15:00
sitebuilderLuc Pattyn1-Nov-09 15:00 
GeneralRe: How to test equality Pin
supercat91-Nov-09 17:01
supercat91-Nov-09 17:01 
GeneralRe: How to test equality Pin
Robert Surtees6-Nov-09 7:32
Robert Surtees6-Nov-09 7:32 
GeneralRe: How to test equality Pin
Nemanja Trifunovic10-Nov-09 11:37
Nemanja Trifunovic10-Nov-09 11:37 
GeneralString of Horror Pin
Izisin28-Oct-09 9:01
Izisin28-Oct-09 9:01 
GeneralRe: String of Horror Pin
Adam Maras28-Oct-09 10:42
Adam Maras28-Oct-09 10:42 
GeneralRe: String of Horror Pin
Jaime Olivares31-Oct-09 19:31
Jaime Olivares31-Oct-09 19:31 
GeneralRe: String of Horror Pin
dojohansen7-Jan-10 23:20
dojohansen7-Jan-10 23:20 
Generaltrying to figure out if number is negative PinPopular
Omar Gameel Salem26-Oct-09 1:19
professionalOmar Gameel Salem26-Oct-09 1:19 
GeneralRe: trying to figure out if number is negative Pin
J4amieC26-Oct-09 1:46
J4amieC26-Oct-09 1:46 
GeneralRe: trying to figure out if number is negative Pin
Jarek Kruza26-Oct-09 1:55
Jarek Kruza26-Oct-09 1:55 
GeneralRe: trying to figure out if number is negative Pin
Omar Gameel Salem26-Oct-09 2:21
professionalOmar Gameel Salem26-Oct-09 2:21 
GeneralRe: trying to figure out if number is negative Pin
Jarek Kruza26-Oct-09 2:31
Jarek Kruza26-Oct-09 2:31 
GeneralRe: trying to figure out if number is negative Pin
Omar Gameel Salem26-Oct-09 3:06
professionalOmar Gameel Salem26-Oct-09 3:06 
JokeRe: trying to figure out if number is negative Pin
AspDotNetDev30-Oct-09 17:08
protectorAspDotNetDev30-Oct-09 17:08 
GeneralRe: trying to figure out if number is negative Pin
Jeroen De Dauw26-Oct-09 3:13
Jeroen De Dauw26-Oct-09 3:13 
GeneralRe: trying to figure out if number is negative Pin
PIEBALDconsult26-Oct-09 4:40
mvePIEBALDconsult26-Oct-09 4:40 

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.