Click here to Skip to main content
15,891,033 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: What was the most interesting, funny or silly Code you have ever read? Pin
BrainiacV23-Oct-12 3:48
BrainiacV23-Oct-12 3:48 
GeneralRe: What was the most interesting, funny or silly Code you have ever read? Pin
Patrick Fox23-Oct-12 4:07
Patrick Fox23-Oct-12 4:07 
GeneralRe: What was the most interesting, funny or silly Code you have ever read? Pin
Phil_Murray23-Oct-12 4:39
Phil_Murray23-Oct-12 4:39 
GeneralRe: What was the most interesting, funny or silly Code you have ever read? Pin
Patrick Fox23-Oct-12 4:58
Patrick Fox23-Oct-12 4:58 
GeneralRe: What was the most interesting, funny or silly Code you have ever read? Pin
Mike Marynowski23-Oct-12 8:00
professionalMike Marynowski23-Oct-12 8:00 
GeneralRe: What was the most interesting, funny or silly Code you have ever read? Pin
Member 841460023-Oct-12 6:17
Member 841460023-Oct-12 6:17 
GeneralRe: What was the most interesting, funny or silly Code you have ever read? Pin
Sentenryu23-Oct-12 23:19
Sentenryu23-Oct-12 23:19 
Generalis_even(int value) Pin
ForestHymn23-Oct-12 6:50
ForestHymn23-Oct-12 6:50 
This is going back many years, and from memory it went something like this:

C++
- (bool)is_even(int value)
{
    if (value == 0)
    {
        return true;
    }
    else if (value == 2)
    {
        return true;
    }
    else if (value == 4)
    {
        return true;
    }
    ...
    else if (value == 12)
    {
        return true;
    }
    
    return false;
}


And so it went to 12 and I guess for the context in which it was used it apparently was a high enough number. You could of course replace this method using a simple modulus operation.

What's also funny is that I saw this code in a printout on the wall of an engineer, which had been there for a couple years. A short time after, another engineer, new to the group, found this method still existing in another part of the code base (apparently just copy-pasted from its original location). The code base was very large.

Lesson learned is if you find bad code somewhere do a global search to insure it is not duplicated anywhere else.
GeneralRe: is_even(int value) Pin
Member 858314523-Oct-12 20:46
Member 858314523-Oct-12 20:46 
JokeRe: is_even(int value) Pin
HaBiX29-Oct-12 21:48
HaBiX29-Oct-12 21:48 
GeneralRe: What was the most interesting, funny or silly Code you have ever read? Pin
sappo23-Oct-12 16:42
sappo23-Oct-12 16:42 
GeneralRe: What was the most interesting, funny or silly Code you have ever read? Pin
dxk24124-Oct-12 3:21
dxk24124-Oct-12 3:21 
GeneralRe: What was the most interesting, funny or silly Code you have ever read? Pin
Brisingr Aerowing24-Oct-12 13:27
professionalBrisingr Aerowing24-Oct-12 13:27 
GeneralRe: What was the most interesting, funny or silly Code you have ever read? Pin
dxk24120-Nov-12 7:39
dxk24120-Nov-12 7:39 
GeneralRe: What was the most interesting, funny or silly Code you have ever read? Pin
Brisingr Aerowing20-Nov-12 11:43
professionalBrisingr Aerowing20-Nov-12 11:43 
GeneralRe: What was the most interesting, funny or silly Code you have ever read? Pin
BlackMilan24-Oct-12 21:23
BlackMilan24-Oct-12 21:23 
GeneralRe: What was the most interesting, funny or silly Code you have ever read? Pin
Chris Quinn24-Oct-12 23:21
Chris Quinn24-Oct-12 23:21 
GeneralBad Websites Pin
Marco Bertschi17-Oct-12 23:50
protectorMarco Bertschi17-Oct-12 23:50 
GeneralRe: Bad Websites Pin
V.18-Oct-12 2:02
professionalV.18-Oct-12 2:02 
GeneralRe: Bad Websites Pin
Shahriar Iqbal Chowdhury/Galib19-Oct-12 11:19
professionalShahriar Iqbal Chowdhury/Galib19-Oct-12 11:19 
GeneralRe: Bad Websites Pin
Marco Bertschi21-Oct-12 23:41
protectorMarco Bertschi21-Oct-12 23:41 
GeneralEgregious Use of Flash PinPopular
IndifferentDisdain17-Oct-12 8:36
IndifferentDisdain17-Oct-12 8:36 
GeneralRe: Egregious Use of Flash Pin
MehGerbil17-Oct-12 8:55
MehGerbil17-Oct-12 8:55 
GeneralRe: Egregious Use of Flash Pin
OriginalGriff17-Oct-12 9:09
mveOriginalGriff17-Oct-12 9:09 
GeneralRe: Egregious Use of Flash Pin
fjdiewornncalwe17-Oct-12 9:11
professionalfjdiewornncalwe17-Oct-12 9:11 

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.