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

 
JokeRe: Comedy code comment misdirection Pin
kmoorevs9-Jul-15 11:01
Memberkmoorevs9-Jul-15 11:01 
JokeRe: Comedy code comment misdirection Pin
Eddy Vluggen8-Jul-15 11:30
professionalEddy Vluggen8-Jul-15 11:30 
GeneralRe: Comedy code comment misdirection Pin
Duncan Edwards Jones8-Jul-15 11:43
professionalDuncan Edwards Jones8-Jul-15 11:43 
GeneralRe: Comedy code comment misdirection Pin
Sander Rossel13-Jul-15 11:49
professionalSander Rossel13-Jul-15 11:49 
GeneralRe: Comedy code comment misdirection Pin
Eddy Vluggen20-Jul-15 10:28
professionalEddy Vluggen20-Jul-15 10:28 
GeneralRe: Comedy code comment misdirection Pin
Sander Rossel21-Jul-15 8:50
professionalSander Rossel21-Jul-15 8:50 
GeneralRe: Comedy code comment misdirection Pin
Power Puff Boy27-Jul-15 3:59
MemberPower Puff Boy27-Jul-15 3:59 
Generalif...else if.. & bad casting Pin
Robin Imrie7-Jul-15 22:53
professionalRobin Imrie7-Jul-15 22:53 
I recently started a new job and my first project it to do a maintenance release of one of the companies products. Yesterday I found code like this...

C++
if ((CString)presuffixS.GetAt(i) == "%")    {   // Add ID, TYPE, FORMAT
    if ((CString)presuffixS.GetAt(i+1) == "i")  {
        presuffix = presuffix + szDeviceID;
        i++;
    }
    else if ((CString)presuffixS.GetAt(i+1) == "t") {
        presuffix = presuffix + szType;
        i++;
    }
    else if ((CString)presuffixS.GetAt(i+1) == "n") {
        presuffix = presuffix + szId;
        i++;
    }

    // and so it continues for and other 6 if elses
}


Could it be any less efficient? I also found this technique used several other places too!
Thanks,
Robin.

GeneralRe: if...else if.. & bad casting Pin
Power Puff Boy27-Jul-15 20:48
MemberPower Puff Boy27-Jul-15 20:48 
GeneralRe: if...else if.. & bad casting Pin
Robin Imrie27-Jul-15 22:07
professionalRobin Imrie27-Jul-15 22:07 
GeneralFun with touchpads Pin
Mike Gaskey4-Jul-15 5:23
MemberMike Gaskey4-Jul-15 5:23 
GeneralRe: Fun with touchpads Pin
Afzaal Ahmad Zeeshan4-Jul-15 6:16
mveAfzaal Ahmad Zeeshan4-Jul-15 6:16 
GeneralRe: Fun with touchpads Pin
PIEBALDconsult4-Jul-15 16:47
professionalPIEBALDconsult4-Jul-15 16:47 
GeneralRe: Fun with touchpads Pin
Mike Gaskey5-Jul-15 11:22
MemberMike Gaskey5-Jul-15 11:22 
GeneralRe: Fun with touchpads Pin
Thanks78726-Jul-15 0:25
professionalThanks78726-Jul-15 0:25 
GeneralRe: Fun with touchpads Pin
Sentenryu6-Jul-15 3:44
MemberSentenryu6-Jul-15 3:44 
GeneralRe: Fun with touchpads Pin
Fueled By Decaff8-Jul-15 22:25
MemberFueled By Decaff8-Jul-15 22:25 
GeneralRe: Fun with touchpads Pin
Gary R. Wheeler18-Jul-15 6:21
MemberGary R. Wheeler18-Jul-15 6:21 
GeneralWhen Default is not the default Pin
kmoorevs30-Jun-15 8:06
Memberkmoorevs30-Jun-15 8:06 
GeneralRe: When Default is not the default Pin
Richard Deeming30-Jun-15 8:16
mveRichard Deeming30-Jun-15 8:16 
GeneralRe: When Default is not the default Pin
Sander Rossel3-Jul-15 22:14
professionalSander Rossel3-Jul-15 22:14 
GeneralFun with pointers in C++ Pin
C3D125-Jun-15 23:57
professionalC3D125-Jun-15 23:57 
GeneralRe: Fun with pointers in C++ Pin
Daniel Pfeffer26-Jun-15 0:12
professionalDaniel Pfeffer26-Jun-15 0:12 
GeneralRe: Fun with pointers in C++ Pin
Mladen Janković26-Jun-15 2:13
MemberMladen Janković26-Jun-15 2:13 
GeneralRe: Fun with pointers in C++ Pin
Daniel Pfeffer26-Jun-15 5:59
professionalDaniel Pfeffer26-Jun-15 5:59 

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.