The best programming skillz ever!



  • It's 8:56.. I'm exhausted from lack of sleep.. I want the world to end in a fiery inferno of destruction, and I've just located this MIND NUMBINGLY horrific example of how there are too many programmers in the wild earning money they don't deserve..

     

    if($chosen_store){
        $chosen_store=$chosen_store;
    }else{
     ... 

    }

    Am I really seeing that? Is this really happening? Whoa. 



  • I know!  I hate it when people put the else on the same line as the brackets, too!



  • @bstorer said:

    I know!  I hate it when people put the else on the same line as the brackets, too!

    Psh, everyone knows the bracket looks better on the same line. Only noobs put the bracket on the second line!

    This programmer was obviously not a noob. Good job to him!
     



  •  This is what I've got (I've only added the translated comments):

     
    <font color="green"> //isSup : retourne vrai si un int ou float (val) est supérieur à un autre (min)
    // [English] isSup : return true if an int or float (val) is greater than another (min) </font>
    function isSup(val,min)
    {
        return (val >= min) ? true : false;
    }

    <font color="green"> //isInf : retourne vrai si un int ou float (val) est inférieur à un autre (max)
    // [English] isInf : return true if an int or float (val) is less than another (max)
    </font> function isInf(val,max)
    {
        return (val <= max) ? true : false;
    }

    <font color="green"> //isDigitSupAndInf : retourne vrai si un int ou un float (val) est borné entre min et max
    // [English] isDigitSupAndInf : return true if an int or float (val) is between min and max
    </font> function isDigitSupAndInf(val,min,max)
    {
        return (isSup(obj,min) && isInf(obj,max)) ? true :false;
    }



  • Well, I hate to tell you, but that's just plain ridiculous.

     if () {

    } else {

    }

    Why pointlessly waste lines?
     



  • @Zecc said:

     This is what I've got (I've only added the translated comments):

     
    <font color="green"> //isSup : retourne vrai si un int ou float (val) est supérieur à un autre (min)
    // [English] isSup : return true if an int or float (val) is greater than another (min) </font>
    function isSup(val,min)
    {
        return (val >= min) ? true : false;
    }
    ...cut...

     

    Wow.. Man.. . just .. Wow.

     



  • @neuralfraud said:

    It's 8:56.. I'm exhausted from lack of sleep.. I want the world to end in a fiery inferno of destruction, and I've just located this MIND NUMBINGLY horrific example of how there are too many programmers in the wild earning money they don't deserve..

     

    if($chosen_store){
        $chosen_store=$chosen_store;
    }else{
     ... 

    }

    Am I really seeing that? Is this really happening? Whoa. 

    I've had that problem before It's usually because I simplified my code and eliminated a useless variable, then did a find/replace to change it to the equivalent variable. Sometimes there's an assignment that I won't notice that ends up looking like that.

    Either that, or the person's on drugs. You never know. :)

    And, and next-line-brackets win! Spaced out code almost always looks cleaner!  



  • @neuralfraud said:

    Wow.. Man.. . just .. Wow.

     
    It's from the same javascript file where they do:

    [...snip...] 

    switch(objType)
    {
        case 'date':
            ti = i;
            if(!isDate(document.getElementById(arMandatoryFields[i]).value)){                   
                alert(arMandatoryFields[ti+2]);
                return false;
            }
            i = ti;
            break;

        case 'textarea' :
        case 'text':

            if(obj2 && obj2.value == "")
            {
                alert(arMandatoryFields[i+2]);
                obj2.focus();
                return false;
            }
            break;
        case 'hidden':
            if(obj2.name.substring(0,2) != 'dt' && obj2.value == "")
            {
                alert(arMandatoryFields[i+2]);
                obj2.focus();                                               <font color="green">// Focus on a hidden input field!</font>
                return false;
            }

            break;
        case 'password':
            if(obj2.value == "")
            {
                alert( arMandatoryFields[i+2]);                  <font color="green">// Don't you love copy paste?</font>
                obj2.focus();
                return false;
            }
            break;
        case 'file':
            if(obj2.value == "")
            {
                alert(arMandatoryFields[i+2]);                  <font color="green">// I know they do</font>
                obj2.focus();
                return false;
            }
            break;

    [...snip...]

     BTW: no variable named obj anywhere. I guess it sounded to generic. So they jumped right over to obj2
     



  • It could also be a line to put a breakpoint on.



  • Judging by the rest of the code-attrocities I've inherited.. I wouldn't give him the benefit of the doubt on that one.. that's just giving him too much credit IMO.
     

    @Thief^ said:

    It could also be a line to put a breakpoint on.



  • @neuralfraud said:

    @Zecc said:

     This is what I've got (I've only added the translated comments):

     
    <font color="green"> //isSup : retourne vrai si un int ou float (val) est supérieur à un autre (min)
    // [English] isSup : return true if an int or float (val) is greater than another (min) </font>
    function isSup(val,min)
    {
        return (val >= min) ? true : false;
    }
    ...cut...

     

    Wow.. Man.. . just .. Wow.

    Along the same lines, in an application I inherited :

    base.setVerified(temp.equalsIgnoreCase("yes") ? new Boolean(true).booleanValue() : new Boolean(false).booleanValue());  



  • @neuralfraud said:

    Well, I hate to tell you, but that's just plain ridiculous.

     if () {

    } else {

    }

    Why pointlessly waste lines?
     

    Is there a shortage that I'm unaware of?



  • @bstorer said:

    @neuralfraud said:

    Well, I hate to tell you, but that's just plain ridiculous.

     if () {

    } else {

    }

    Why pointlessly waste lines?
     

    Is there a shortage that I'm unaware of?

    yes. There is a shortage of screen real estate on my flat screen. 



  • I can't give this any credit

    if($chosen_store)

    {
        $chosen_store=$chosen_store;
    }

    else

    {
     ... 

    }

    Read that again.  What the Chosen store is 1 then 1 = 1, if it is anything other than 1, well, we get to the else.  Even removal of variables and a replace process doesn't seem to account for this. 

    Oh and I formatted the code properly, if you disagree, you are wrong.



  • @patrek said:

    Along the same lines, in an application I inherited :

    base.setVerified(temp.equalsIgnoreCase("yes") ? new Boolean(true).booleanValue() : new Boolean(false).booleanValue());  

    Awww Pleeease! I just spit my coffee on my screen and keyboard laughing out loud. (now the screen real estate gets even more sparse...) 



  • @KattMan said:

    Oh and I formatted the code properly, if you disagree, you are wrong.

    Lets either agree on disagreeing or then start a war...   :P 



  • @TheRider said:

    @KattMan said:

    Oh and I formatted the code properly, if you disagree, you are wrong.

    Lets either agree on disagreeing or then start a war...   :P 

    No need for a war, you disagree, you are wrong, end of story.  ;) 



  • That's up there with this one from my 3rd evar job.

     

    All done in a proprietary language, by the way (written by Laslo, the guy who lived in the mechanical room in "Real Genius")

     

    ...

    I=I

    I=I

    I=I

    I=I

    I=I

    I=I

    IF (I=I) THEN....

     


     

    Apparently you had to assign things 6 times to get them to stick, I guess.


     

     

     



  • @unklegwar said:

    That's up there with this one from my 3rd evar job.

    All done in a proprietary language, by the way (written by Laslo, the guy who lived in the mechanical room in "Real Genius")

    ...

    I=I

    I=I

    I=I

    I=I

    I=I

    I=I

    IF (I=I) THEN....

     

    Apparently you had to assign things 6 times to get them to stick, I guess.

    Hmm, looks strangely like..umm VB6!  So Laslo wrote a proprietary language that looks and acts like an established language?  What VB doesn't need you to assign vars multiple times?  With some of the code I seen I'd be hard pressed to believe that.

     

    At least Laslo got the girl in the end, and the winnebago and ski-doo and the trailer, and the computer and the.......



  • @neuralfraud said:

    @Thief^ said:

    It could also be a line to put a breakpoint on.


    You do the $var=$var; so you have something to stop on for a breakpoint. Then you can just click on the var to see the value. 

    It makes sense!  

     



  • @KattMan said:

    I can't give this any credit

    if($chosen_store)

    {
        $chosen_store=$chosen_store;
    }

    else

    {
     ... 

    }

    Read that again.  What the Chosen store is 1 then 1 = 1, if it is anything other than 1, well, we get to the else.  Even removal of variables and a replace process doesn't seem to account for this. 

    Oh and I formatted the code properly, if you disagree, you are wrong.

    The original code may have been (excusing boring variable names):

    if($var1)
    {
        $var2 = $var1;
    }
    else
    {
        ...
    }

    Which only makes the assignment if $var1 was set. Then somebody realizes that $var1 is always set, and does a find/replace to change everything to $var2 without looking at every single line. You obviously end up with:

     

    if($var2)

    {

        $var2 = $var2;

    }

    else

    {

        ...

    }




  • @rbowes said:

    The original code may have been (excusing boring variable names):

    if($var1)
    {
        $var2 = $var1;
    }
    else
    {
        ...
    }

    Which only makes the assignment if $var1 was set. Then somebody realizes that $var1 is always set, and does a find/replace to change everything to $var2 without looking at every single line. You obviously end up with:

     

    if($var2)

    {

        $var2 = $var2;

    }

    else

    {

        ...

    }


    I would agree with you if the variable name wasn't actually meaningful. 

    Why change the chosen store, especially to something that equates to a boolean check?



  • @plazmo said:

    @neuralfraud said:

    @Thief^ said:

    It could also be a line to put a breakpoint on.


    You do the $var=$var; so you have something to stop on for a breakpoint. Then you can just click on the var to see the value. 

    It makes sense!  

     

    It's useless as a break point when it is inside an If statement.

    Please it before the if so you can see the value regardless of process.  So if this was the reason for it, it's still a WTF.



  • @KattMan said:

    @rbowes said:

    The original code may have been (excusing boring variable names):

    if($var1)
    {
        $var2 = $var1;
    }
    else
    {
        ...
    }

    Which only makes the assignment if $var1 was set. Then somebody realizes that $var1 is always set, and does a find/replace to change everything to $var2 without looking at every single line. You obviously end up with:

     

    if($var2)

    {

        $var2 = $var2;

    }

    else

    {

        ...

    }


    I would agree with you if the variable name wasn't actually meaningful. 

    Why change the chosen store, especially to something that equates to a boolean check?

    Who says it's boolean? Maybe it's an object and he was verifying that it isn't NULL before sending it. Then the find/replace that I mentioned earlier could have made the code stupid-looking.  



  • @KattMan said:

    @plazmo said:
    @neuralfraud said:

    @Thief^ said:

    It could also be a line to put a breakpoint on.


    You do the $var=$var; so you have something to stop on for a breakpoint. Then you can just click on the var to see the value. 

    It makes sense!  

     

    It's useless as a break point when it is inside an If statement.

    Please it before the if so you can see the value regardless of process.  So if this was the reason for it, it's still a WTF.

    If the condition is only true one time out of several thousand, and you either have a debugger that doesn't do conditional breakpoints (or where they are hard to set up) then this makes sense



  • @GettinSadda said:

    @KattMan said:
    @plazmo said:
    @neuralfraud said:

    @Thief^ said:

    It could also be a line to put a breakpoint on.


    You do the $var=$var; so you have something to stop on for a breakpoint. Then you can just click on the var to see the value. 

    It makes sense!  

     

    It's useless as a break point when it is inside an If statement.

    Please it before the if so you can see the value regardless of process.  So if this was the reason for it, it's still a WTF.

    If the condition is only true one time out of several thousand, and you either have a debugger that doesn't do conditional breakpoints (or where they are hard to set up) then this makes sense

    in that case, better to use an assert.

    Unless your language doesn't support asserts. 



  • @KattMan said:

    @GettinSadda said:
    @KattMan said:
    ..snip..@plazmo said:
    You do the $var=$var; so you have something to stop on for a breakpoint. Then you can just click on the var to see the value. 

    It makes sense!  

    It's useless as a break point when it is inside an If statement.

    Please it before the if so you can see the value regardless of process.  So if this was the reason for it, it's still a WTF.

    If the condition is only true one time out of several thousand, and you either have a debugger that doesn't do conditional breakpoints (or where they are hard to set up) then this makes sense

    in that case, better to use an assert.

    Unless your language doesn't support asserts. 

    No, an assert is used where the condition is a major fatal error.

    In this case it could well be a valid condition that is a useful indicator of a state that may need to be stepped through during debugging.



  • @GettinSadda said:

    @KattMan said:
    @GettinSadda said:
    @KattMan said:
    ..snip..@plazmo said:
    You do the $var=$var; so you have something to stop on for a breakpoint. Then you can just click on the var to see the value. 

    It makes sense!  

    It's useless as a break point when it is inside an If statement.

    Please it before the if so you can see the value regardless of process.  So if this was the reason for it, it's still a WTF.

    If the condition is only true one time out of several thousand, and you either have a debugger that doesn't do conditional breakpoints (or where they are hard to set up) then this makes sense

    in that case, better to use an assert.

    Unless your language doesn't support asserts. 

    No, an assert is used where the condition is a major fatal error.

    In this case it could well be a valid condition that is a useful indicator of a state that may need to be stepped through during debugging.

    Then use a conditional watch list, break when your value is true.  Of course, unless your IDE doesn't support that. 



  • @KattMan said:

    @GettinSadda said:
    @KattMan said:
    @GettinSadda said:
    @KattMan said:
    ..snip..@plazmo said:
    You do the $var=$var; so you have something to stop on for a breakpoint. Then you can just click on the var to see the value. 

    It makes sense!  

    It's useless as a break point when it is inside an If statement.

    Please it before the if so you can see the value regardless of process.  So if this was the reason for it, it's still a WTF.

    If the condition is only true one time out of several thousand, and you either have a debugger that doesn't do conditional breakpoints (or where they are hard to set up) then this makes sense

    in that case, better to use an assert.

    Unless your language doesn't support asserts. 

    No, an assert is used where the condition is a major fatal error.

    In this case it could well be a valid condition that is a useful indicator of a state that may need to be stepped through during debugging.

    Then use a conditional watch list, break when your value is true.  Of course, unless your IDE doesn't support that. 

    Ok I missed where you mention that your debugger doesn't have conditional breakpoints.

    But I still don't see the reasoning here, simply because of the else side of things.  I would think you would still want to process, even that one in a thousand event.

    if(var){

    var = var;}

    then continue processing as normal.  It's the else side that throws off this idea.  Still a WTF. 



  • whoa guys. slow down!!!

     

    You people are putting WAY too much thought into this WTF... making it much less fun than it really is.

     

    Here, have some context.

     

    $chosen_store is an integer number, of a store_id.

     

    In the usage of my example, it checks to see if $chosen_store is set, and if so, well, you gotta evaluate something right? so there you have $chosen_store=$chosen_store... and then the else.

     



    Better is:

    if (!isset($chosen_store)) {

     {code}

    }

    Boom. Done. 

    This aint a breakpoint, its not a typo and it certainly isn't checking for a boolean. it was purposely coded this way. That makes it a real big WTF.

     

    PS: Thanks for all the hilarious similar examples ;)

     



  • A helpful tip

    Happy to help.  :) 



  • bstorer, that's the first time I've ever laughed out loud reading this forum.

    Thanks for breaking up my day! 



  • It obviously should have been

    $chosen_store = $chosen_store ? $chosen_store : $not_chosen_store; // sets $chosen_store



  • @KattMan said:

    @unklegwar said:

    That's up there with this one from my 3rd evar job.

    All done in a proprietary language, by the way (written by Laslo, the guy who lived in the mechanical room in "Real Genius")

    ...

    I=I

    I=I

    I=I

    I=I

    I=I

    I=I

    IF (I=I) THEN....

     

    Apparently you had to assign things 6 times to get them to stick, I guess.

    Hmm, looks strangely like..umm VB6!  So Laslo wrote a proprietary language that looks and acts like an established language?  What VB doesn't need you to assign vars multiple times?  With some of the code I seen I'd be hard pressed to believe that.

     

    At least Laslo got the girl in the end, and the winnebago and ski-doo and the trailer, and the computer and the.......

    I dunno if this Laslo got chix, but I know he got the chEx, as in paychex.. If only I could recall more of the code, as it was very much VB-esque, but certainly still far off. But alas, I have buried that memory in a place where only my therapist can find it. I should add that it only allowed 4 letter var names. Not even 6, as provided by RPG, but only 4!

     


Log in to reply