Click here to Skip to main content

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, embarrasing 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.

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page  Show 
GeneralRe: The best refactoring I have ever seenmemberPIEBALDconsult17 Jan '13 - 3:48 
Oh indeed, put it in a header file; not the code files. Code files should contain very few directives.
GeneralRe: The best refactoring I have ever seenmemberRob Grainger1 Feb '13 - 3:17 
I think you'll find the technical term is refuctoring.
GeneralWhat was I thinkingmemberdjj5516 Jan '13 - 1:15 
While editing a much tweaked process that I wrote, I found this T-SQL:
DECLARE @NumDays INT; 
SELECT @NumDays = 
    CASE 
        WHEN @Client = 'Client1' THEN @DaysBack 
        WHEN @Client = 'Client2' THEN @DaysBack 
        ELSE @DaysBack 
    END; 
This is what happens when you go from actual numbers to a variable, without checking the code. Blush | :O
GeneralRe: What was I thinkingmemberDavid Goebet16 Jan '13 - 1:40 
yeah you clearly missed the
 
@DaysBack 
 
Poke tongue | ;-P
is this a signature ?

GeneralRe: What was I thinkingmemberMatt U.16 Jan '13 - 1:56 
I've done something similar to this recently. It was like this:
 
SELECT CASE
    WHEN Field1 = 'Something #1' THEN 'Result #1'
    WHEN Field1 = 'Something #2' THEN 'N/A'
    WHEN Field1 = 'Something #3' THEN '(Empty)'
    ELSE 'N/A'
    END
 
And I continued to wonder why even when 'Something #1' was not met, I was seeing 'N/A' in the results. Took me a bit to figure it out. D'Oh! | :doh:
djj55: Nice but may have a permission problem
Pete O'Hanlon: He has my permission to run it.

GeneralRe: What was I thinkingmemberpeterchen16 Jan '13 - 3:24 
djj55 wrote:
What was I thinking

 
about Client3's perky assets?

GeneralRe: What was I thinkingmemberG James16 Jan '13 - 9:57 
My personal favorite from C#. Someone was testing the value of a boolean variable.
 
if (someBooleanVariable == true)
    return true;
else
    return false;
 
Later they refactored it to this thinking it was an improvement. Smile | :)
return someBooleanVariable == true ? true : false;

JokeRe: What was I thinkingadminChris Maunder16 Jan '13 - 18:02 
You mean they missed the totally obvious contraction to
return someBooleanVariable ? true : false
They should hang their head in shame!
cheers,
Chris Maunder
 
The Code Project | Co-founder
Microsoft C++ MVP

GeneralRe: What was I thinkingmember33deepak16 Jan '13 - 18:13 
well, it should be just
 
return someBooleanVariable
Big Grin | :-D
GeneralRe: What was I thinkingadminChris Maunder16 Jan '13 - 18:14 
Roll eyes | :rolleyes:
cheers,
Chris Maunder
 
The Code Project | Co-founder
Microsoft C++ MVP

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web01 | 2.6.130523.1 | Last Updated 23 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid