This makes me sad and angry



  • Found this in the codebase today. Also note: this has not been anonymized in any way. This is straight of a .cs file.

    <html><body style='color:#000000; background:#ffffff; '>
    public bool Reverse(bool bolParam)
        {
            bool bolReturn;
            if (bolParam == true)
            {
                bolReturn = false;
            }
            else
            {
                bolReturn = true;
            }
            return bolReturn;
        }
    


  • But I wrote a bunch of unit tests; they all pass. This MUST be well-implemented code!!!


  • Considered Harmful

    You can just type this method in if you're ever using a keyboard without an exclamation point key. Boom, problem solved.



  • Should have passed bolParam by reference to avoid making another boolean for the return value.



  • It makes me sad that this code seems mundane instead of eye-popping.

    Then again, talk of purple dildos and furries feel rather old-hat as well...



  • If anyone's interested, here's what I checked-in as a replacement:

    <html><body style='color:#000000; background:#ffffff; '>
       /*
        * The following method is being retained for historical
        * purposes. It is best not to look directly at it, for
        * it is borne of the darkness and insanity that drives
        * men to do terrible things. But know this: monsters are real.
        * But they don't live under your bed or in your closet. They
        * live in your dev teams and your repos. And they write
        * USELESS FUCKING STUPID SHITTY METHODS LIKE THIS.         
        * 
        * 
    public bool Reverse(bool bolParam)
    {
        bool bolReturn;
        if (bolParam == true)
        {
            bolReturn = false;
        }
        else
        {
            bolReturn = true;
        }
        return bolReturn;
    }
    */
    
    public bool Reverse(bool b)
    {
        return !b;
    }
    

  • Considered Harmful

    You forgot:

    [Obsolete( "Use ! instead" )]



  • No no no no noooooo.



    if (bolParam == true)

    {

    bolReturn = false;

    }

    else if (bolPaam == false)

    {

    bolReturn = true;

    }

    else

    {

    throw new BoolNotReversedException();

    }



    (I wish I knew how to make these forums work properly without too much fucking around)


  • Considered Harmful

    I'm surprised no one's built a WTFy Community Server UI layer that scrapes the actual TDWTF site but forces it to be usable.



  • @joe.edwards said:

    I'm surprised no one's built a WTFy Community Server UI layer that scrapes the actual TDWTF site but forces it to be usable.

    Did you just volunteer?



  • @joe.edwards said:

    You can just type this method in if you're ever using a keyboard without an exclamation point key. Boom, problem solved.

    No exclamation point needed if you expanded !bolParam out to:

      bolParam = bolParam == false

    Oh, and the function the OP posted could be useful if you needed to pass a delegate/callback to another function and it passed a single true/false value wherein you wanted the opposite value to be returned....without any extra logic, but then they could have shortened it in the function still...

     



  • @Mythran said:

    Oh, and the function the OP posted could be useful if you needed to pass a delegate/callback to another function and it passed a single true/false value wherein you wanted the opposite value to be returned....without any extra logic, but then they could have shortened it in the function still...

    No, nothing so logical. This whole thing is a major wtf.


  • Considered Harmful

    @Mythran said:

    Oh, and the function the OP posted could be useful if you needed to pass a delegate/callback to another function and it passed a single true/false value wherein you wanted the opposite value to be returned....without any extra logic, but then they could have shortened it in the function still...

    x => !x



  • @DrPepper said:

    But I wrote a bunch of unit tests; they all pass. This MUST be well-implemented code!!!

    If it's a WTF and the unit tests all pass, it's not a WTF.



  • @mikeTheLiar said:

    If anyone's interested, here's what I checked-in as a replacement:

       /*
        * The following method is being retained for historical
        * purposes. It is best not to look directly at it, for
        * it is borne of the darkness and insanity that drives
        * men to do terrible things. But know this: monsters are real.
        * But they don't live under your bed or in your closet. They
        * live in your dev teams and your repos. And they write
        * USELESS FUCKING STUPID SHITTY METHODS LIKE THIS.         
        * 
        * 
    public bool Reverse(bool bolParam)
    {
        bool bolReturn;
        if (bolParam == true)
        {
            bolReturn = false;
        }
        else
        {
            bolReturn = true;
        }
        return bolReturn;
    }
    */
    

    public bool Reverse(bool b)
    {
    return !b;
    }

     

    But does your replacement method return the right value when bolParam is FILE_NOT_FOUND?

     



  • Even the existence of this method, the single idea of "I know, I'll write a function to do this" is a bigger WTF than the implementation itself.



  • @ubersoldat said:

    Even the existence of this method, the single idea of "I know, I'll write a function to do this" is a bigger WTF than the implementation itself.

    It's even worse than you think. Maybe I'll post the rest of it tomorrow, after I've sobered up. I found some particularly fucked up code today, and as a result am taking solace in a bottle of gin.



  • @mikeTheLiar said:

    public bool Reverse(bool b)
    {
    return !b;
    }

    You need to pay it forward to the next guy who will maintain the code. Put this one instead:

    
    public bool Reverse(bool b)
    {
    
        bool reversed;
    
         //todo remove the try part
         try 
         {
             reversed = Convert.ToBoolean(1 - (1 / b.GetHashCode()));
         }
         finally
         {
             return (reversed == b);
         }
           
    }
    
    


  • @ubersoldat said:

    Even the existence of this method, the single idea of "I know, I'll write a function to do this" is a bigger WTF than the implementation itself.
     

     You never know when the language might decide to change the meaning of operator !.   Now, rather than change every piece of code with an exclamation point anywhere in it, you just need to change the one function!



  • "Borne of the darkness" makes me sad and angry.



  • @Cat said:

    You never know when the language might decide to change the meaning of operator !

    I have a moment of cognitive dissonance every time I see a style marked !important.



  • @flabdablet said:

    "Borne of the darkness" makes me sad and angry.

    Yeah, it's spelled "Bourne", duh.



  • @eViLegion said:

    No no no no noooooo.

    if (bolParam == true)
    {
    bolReturn = false;
    }
    else if (bolPaam == false)
    {
    bolReturn = true;
    }
    else
    {
    throw new BoolNotReversedException();
    }
     

    [i][b]Please.[/b][/i]

    [code]if (bolParam == true)
    {
    . . . bolReturn = false;
    }
    else if (bolParam == false)
    {
    . . . bolReturn = true;
    }
    else
    {
    . . . bolReturn = fileFound;
    }[/code]

     



  • @mrputter said:

    @eViLegion said:

    No no no no noooooo.



    if (bolParam == true)

    {

    bolReturn = false;

    }

    else if (bolPaam == false)

    {

    bolReturn = true;

    }

    else

    {

    throw new BoolNotReversedException();

    }
     

    Please.

    <font face="Lucida Console" size="2">if (bolParam == true)
    {
    . . . bolReturn = false;
    }
    else if (bolParam == false)
    {
    . . . bolReturn = true;
    }
    else
    {
    . . . bolReturn = fileFound;
    }</font>

     

    He waited 7 years to make that first post.



  • @joe.edwards said:

    You can just type this method in if you're ever using a keyboard without an exclamation point key. Boom, problem solved.

    Or you could use (bol ^ true) instead. TRWTF being that C# is just as fucked up.



  • @morbiuswilters said:

    He waited 7 years to make that first post.

    Well worth the wait for this tour de force.



  • Missing the bigger picture. He managed to get "special formatting" working properly on his first forum post.



  • @mrputter said:

    Please.

    <font face="Lucida Console" size="2">if (bolParam == true)
    {
    . . . bolReturn = false;
    }
    else if (bolParam == false)
    {
    . . . bolReturn = true;
    }
    else
    {
    . . . bolReturn = fileNotFound;
    }</font>

     



  • @flabdablet said:

    "Borne of the darkness" makes me sad and angry.


    @merriam webster said:
    Definition of BORNE
    :
    past participle of bear

    Goddam it. I fucking fail. My whole life I've been using the wrong word. I am TRWTF.



  • @mikeTheLiar said:

    @flabdablet said:

    "Borne of the darkness" makes me sad and angry.


    @merriam webster said:
    Definition of BORNE
    :
    past participle of bear

    Goddam it. I fucking fail. My whole life I've been using the wrong word. I am TRWTF.

    To be fair, "born" is also the past participle of "bear".


Log in to reply