Click here to Skip to main content
15,911,891 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: Horrible enough for you? Pin
VentsyV1-Oct-08 11:46
VentsyV1-Oct-08 11:46 
GeneralRe: Horrible enough for you? Pin
Lutosław1-Oct-08 12:04
Lutosław1-Oct-08 12:04 
GeneralRe: Horrible enough for you? Pin
Paul Conrad1-Oct-08 18:58
professionalPaul Conrad1-Oct-08 18:58 
GeneralRe: Horrible enough for you? Pin
dojohansen1-Oct-08 22:13
dojohansen1-Oct-08 22:13 
GeneralRe: Horrible enough for you? Pin
Dan Neely2-Oct-08 2:25
Dan Neely2-Oct-08 2:25 
GeneralRe: Horrible enough for you? Pin
rcollina2-Oct-08 1:09
rcollina2-Oct-08 1:09 
GeneralRe: Horrible enough for you? Pin
Tom12-Oct-08 8:27
Tom12-Oct-08 8:27 
GeneralAnd Another One PinPopular
Rick York29-Sep-08 12:22
mveRick York29-Sep-08 12:22 
Horror 1 :

if (strRet[0] == '0' && strRet[1] == '1' && 
    strRet[2] == 'F' && strRet[3] == 'F' && 
    strRet[4] == '2' && strRet[5] == '4')

A piece of code I just looked at had the preceding logic sprinkled through it around twenty times to examine the response from a piece of equipment with comparisons of varying lengths. Apparently this individual has never heard of strncmp or its TCHAR variant _tcsncmp.

Horror 2 :

They wrote their own function essentially equivalent to strtoul. I won't subject you all to it - you'll have to trust me when I say that it is a horror.

Horror 3 :

The function described in Horror 2 is called ConvertHEXASC(). Here's how it is used to convert the data from the equipment :

int iTmp = 0;
iTmp += ConvertHEXASC( strRet[7] ) * 1;      // 16^0
iTmp += ConvertHEXASC( strRet[6] ) * 16;     // 16^1
iTmp += ConvertHEXASC( strRet[5] ) * 256;    // 16^2
iTmp += ConvertHEXASC( strRet[4] ) * 4096;   // 16^3

Now imagine a similar sequence of code used a few dozen times with strings of varying lengths and positions. OMG | :OMG:

Horror 4 :

There were sixteen buttons used to select a property for the equipment and, naturally, there were sixteen different functions made to handle the clicks of the buttons. ON_COMMAND_RANGE anyone ? WTF | :WTF:

The word horror barely scratches the surface for these and the rest of the things I saw there.

It was staggering. Simply staggering.
QuestionRe: And Another One Pin
CPallini29-Sep-08 21:44
mveCPallini29-Sep-08 21:44 
GeneralRe: And Another One Pin
Graham Bradshaw30-Sep-08 2:06
Graham Bradshaw30-Sep-08 2:06 
GeneralRe: And Another One Pin
Mike Dimmick30-Sep-08 5:49
Mike Dimmick30-Sep-08 5:49 
GeneralRe: And Another One Pin
Rick York30-Sep-08 7:09
mveRick York30-Sep-08 7:09 
GeneralAnother Horror PinPopular
Narotham Babu Kalluri26-Sep-08 3:39
Narotham Babu Kalluri26-Sep-08 3:39 
GeneralRe: Another Horror Pin
adamsappel26-Sep-08 3:52
adamsappel26-Sep-08 3:52 
GeneralRe: Another Horror Pin
Paul Conrad26-Sep-08 6:05
professionalPaul Conrad26-Sep-08 6:05 
GeneralRe: Another Horror Pin
CARPETBURNER29-Sep-08 8:59
CARPETBURNER29-Sep-08 8:59 
QuestionRe: Another Horror Pin
CPallini26-Sep-08 4:07
mveCPallini26-Sep-08 4:07 
AnswerRe: Another Horror Pin
Narotham Babu Kalluri26-Sep-08 5:01
Narotham Babu Kalluri26-Sep-08 5:01 
GeneralRe: Another Horror Pin
Paul Conrad26-Sep-08 6:06
professionalPaul Conrad26-Sep-08 6:06 
JokeRe: Another Horror Pin
Single Step Debugger26-Sep-08 5:14
Single Step Debugger26-Sep-08 5:14 
GeneralRe: Another Horror Pin
Paul Conrad26-Sep-08 6:04
professionalPaul Conrad26-Sep-08 6:04 
GeneralRe: Another Horror Pin
Perspx26-Sep-08 6:09
Perspx26-Sep-08 6:09 
GeneralRe: Another Horror Pin
Paul Conrad26-Sep-08 6:11
professionalPaul Conrad26-Sep-08 6:11 
GeneralRe: Another Horror Pin
Perspx26-Sep-08 6:14
Perspx26-Sep-08 6:14 
GeneralRe: Another Horror Pin
Lutosław26-Sep-08 23:01
Lutosław26-Sep-08 23:01 

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.