• Maurits (cs)

    private boolean is04(String authCode)
    {
    if ("02".equals(authCode)) return true;

    Uh... what?
    [Note from Alex: This was a typo when anonymizing it -- I've corrected this]

  • l-user (unregistered)

    04 is 02 and I am first

  • reed (cs) in reply to l-user

    You are number six!

  • pinguis (cs)

    I have no mouth, but i must scream

  • anon (unregistered)

    So is he also 'training' the developers to cram as much code onto one line as possible and to avoid the use of constants?

  • Fist! (unregistered)
    Alex Papadimoulis:


    // brillant!

    private boolean is01(String authCode) { if ("01".equals(authCode)) {
    Console.Write("FIST!");
    return true;
    }
      else return false; }

  • Rusty B (unregistered)

     I wonder how they will handle the 'Case Else' ....

     

    argh

     

  • MikeMontana (cs)

    Yeah, april fools. Too rediculous to be beleived - unless this is the output of some CodeWizard Tool.

  • ParkinT (cs)

    private boolean isBrillant(String authCode)
    {
      if ("paula".equals(authCode)) return true;
      else return false;
    }

  • Manni (cs)

    *snicker* You said "cock".

    This code feels like burning in my special place. I work with a guy that likes to hardcode all sorts of crap like this, and he defines a function for every single thing. If he needs to create 30 different database tables, he'll make 30 separate functions to do it rather than one function that accepts a list of field names and types as parameters.

  • The Internet (unregistered)

    What's the deal with these WTF's recently? Clearly, this is fake. We have not run out of real WTF's yet, have we?

  • Djinn (cs) in reply to The Internet
    Anonymous:
    What's the deal with these WTF's recently? Clearly, this is fake. We have not run out of real WTF's yet, have we?


    No, over functioning is a real syndrome. I have seen it myself.
  • Volmarias (cs) in reply to The Internet

    Gosh, I love the fact that I can't use any BBcode, or HTML tags, or anything like that, JUST BECAUSE I'M USING OPERA. (Hint: Get a better fucking board)

    Maurits said:

    private boolean is04(String authCode) { if ("02".equals(authCode)) return true;

    Uh... what?

    I don't see that, maybe Alex made a booboo and fixed it.

  • Volmarias (cs) in reply to Volmarias

    Yep, mere moments later:

    [Note from Alex: This was a typo when anonymizing it -- I've corrected this]

    Too bad I can't edit my original post, or delete it!

  • DWalker59 (cs) in reply to MikeMontana
    MikeMontana:
    Yeah, april fools. Too rediculous to be beleived - unless this is the output of some CodeWizard Tool.
     
    Why do so many people have trouble spelling "ridiculous"???
  • Coughptcha (cs) in reply to reed
    reed:
    You are number six!
    I am not a number. I am a free man!
  • GoatCheez (cs)

    Stuff like this is grounds for either firing the dumbass that did this, or promoting them to management. WTF man...

  • mrprogguy (cs) in reply to Maurits

    Can someone please tell  me where that

    <FONT face="Courier New">if(condition) return something; else return somethingElse;</FONT>

    idiom came from?

    Why would you need to protect a <FONT face="Courier New">return</FONT> with an <FONT face="Courier New">else</FONT>?  If the return is exercised, then the other clause is ignored! 

    It's even in the original K&R book on C, written by the guys themselves, and it's no less idiotic coming from someone "authoritative."

    That, to me, is a serious WTF.

  • BiggBru (cs)
    Alex Papadimoulis:

    As a consultant, one of Maarten De Cock's responsibilities is to analyze his client's code, identify where the developers could use improvement, and train them on how to write higher-quality code.

    <FONT face=Georgia>And that's when Maarten De Cock slapped the developer with his ... hand. [:P]</FONT>

  • bullseye (cs) in reply to The Internet

    The Internet:
    What's the deal with these WTF's recently? Clearly, this is fake. We have not run out of real WTF's yet, have we?

    These comments are becoming as tiresome as the "first" posts.

    If it is so outlandish, that it looks fake, then welcome to the world of code maintenance.  As I, and any other developer that works in the real world, can attest to, you see stupid stuff like this frequently.

    Instead of looking like a moron (anonymously) who has never had to work with other people's code, you should sit back and be thankful that you haven't encountered this type of crap in your job.

    (And yes, I am admittedly hostile about this because I have been debugging WTFs all day.  On a side note, I think this site has jaded me to bad programming tactics...)

  • Rob (unregistered) in reply to mrprogguy

    Eclipse even warns you that it is a mistake. Hooray for Eclipse :)

  • ChiefCrazyTalk (unregistered) in reply to mrprogguy
    mrprogguy:

    Can someone please tell  me where that

    <FONT face="Courier New">if(condition) return something; else return somethingElse;</FONT>

    idiom came from?

    Why would you need to protect a <FONT face="Courier New">return</FONT> with an <FONT face="Courier New">else</FONT>?  If the return is exercised, then the other clause is ignored! 

    It's even in the original K&R book on C, written by the guys themselves, and it's no less idiotic coming from someone "authoritative."

    That, to me, is a serious WTF.

     

    Simple - so the next guy who comes along and adds a line of code doesn't cause something to break.  This way its clear what is going on, when the intent is, and is more maintainable. 

  • Hubert Farnsworth (cs)

    This is obviously machine generated, so it's ok.

  • cjd (unregistered) in reply to DWalker59

    Probably because there's the E sound when they say it.  It makes perfect cents!

  • An apprentice (unregistered)
    Alex Papadimoulis:
    /**
     * Method is01.
     * @param authCode
     * @return boolean
     */
    private boolean is01(String authCode)
    {
      if ("01".equals(authCode)) return true;
      else return false;
    }

    At least it's properly documented! I wouldn't know this method returns a boolean otherwise. And the name authCode is so self-explaining...

  • Joshua (unregistered) in reply to Coughptcha

    Hah! Ha! Ha! Hah!

    (Seriously: The Prisoner was awesome.)

  • Joshua (unregistered) in reply to Coughptcha

    And, of course, the Real WTF is the forum software. (This coming from an anonymous bastard.) I was quoting the following...

    Coughptcha:
    reed:
    You are number six!
    I am not a number. I am a free man!


  • Tyler (unregistered) in reply to ChiefCrazyTalk

    I agree.  I like the style:
    if (condition) doStuff;

    instead of
    if (condition) {
        doStuff
    }

    I think it's more readable.  I also like the idea of not counting on the returns to avoid the else clause.  however, that's only when we are talking about long if statements (more than 5 lines at least).  it looks pretty stupid to write as much code as they did when half the code would have worked.. (and that's not getting rid of worthless functions).  And yes, people do write functions like that.  people that went to college and memorized certain techniques about coding but never really understood the underlying theory and reasoning behind modularity.

  • jackass (cs) in reply to Djinn

    Djinn:
    Anonymous:
    What's the deal with these WTF's recently? Clearly, this is fake. We have not run out of real WTF's yet, have we?


    No, over functioning is a real syndrome. I have seen it myself.

    I agree, I have seen this many times myself.  All you people who think this is fake are just a bunch of jackasses.

  • Digitalbath (cs) in reply to mrprogguy
    mrprogguy:

    Can someone please tell  me where that

    <FONT face="Courier New">if(condition) return something; else return somethingElse;</FONT>

    idiom came from?

    Why would you need to protect a <FONT face="Courier New">return</FONT> with an <FONT face="Courier New">else</FONT>?  If the return is exercised, then the other clause is ignored! 

    It's even in the original K&R book on C, written by the guys themselves, and it's no less idiotic coming from someone "authoritative."

    That, to me, is a serious WTF.

    This would be much better:

    private boolean is01(String authCode)
    {
      boolean returnboolean = false;

      if ("01".equals(authCode) == true) {

        returnboolean = true;

        return <FONT color=#000000>returnboolean</FONT>;

      }
     else if ("01".equals(authCode) == false) {

        returnboolean = false;

        return <FONT color=#000000>returnboolean;</FONT>

     else {

        returnboolean = false;

        return <FONT color=#000000>returnboolean;</FONT>

    <FONT color=#000000>   }</FONT>

    <FONT color=#000000>  //and just to make sure, ie FileNotFound case </FONT>

    <FONT color=#000000>  return returnboolean;
    }</FONT>

    <FONT color=#000000>//end joke


    </FONT>
  • E (unregistered) in reply to Tyler

    Or, instead of:

    if(condition) return true; else return false;

    How about:

    return condition;

  • davewalthall (cs) in reply to mrprogguy

    The idiom:
      if(cond) return a;
      else return b;
    comes from a very reasonable place.  It implies that b is being returned because cond was not true.  If you instead write:
      if(cond) return a;
      return b;
    it implies that you are returning b because that is the appropriate thing to do if you reach that point, and is unrelated to cond.  I strongly believe that when code layout and structure reflects the underlying logic, that is a good thing. 

    David

    PS An even stronger statement of the idiom is:
      return (cond ? a : b);


  • kipthegreat (cs) in reply to Volmarias
    Volmarias:
    Gosh, I love the fact that I can't use any BBcode, or HTML tags, or anything like that, JUST BECAUSE I'M USING OPERA.


    Opera is for hippies, gays, and terrorists.  Use Firefox.  It's what the cool kids are using.
  • VGR (cs)

    This is sort of a cargo cult thing.  People do this because they don't know why they're doing the things they've been instructed to do.  As a result, they end up taking it all sorts of weird directions.

    Something like this would make a world of difference:

    private boolean isAdministrator(String authCode)
    {
        return "01".equals(authCode);
    }

    private boolean isFurniture(String productCode)
    {
        return "004".equals(productCode) || "005".equals(productCode);
    }

    Not just because the if/else is pruned out (that's a pet peeve of mine, and sure sign that the coder is still living in the world of C or maybe even VB), but because the method's name now makes it an abstraction.  So now it at least has some worth.

  • kiptheretard (unregistered) in reply to kipthegreat

    kipthegreat:

    Opera is for hippies, gays, and terrorists.  Use Firefox.  It's what the cool kids are using.

    Yeah, screw standardisation and the basis of inter-machine communication, just as long as everyone's a squealing script kiddie and using the same "kewl" browser. Hey, I hear Firefox has the best support for "Web 2.0". lolz.

  • Alun Jones (unregistered) in reply to davewalthall

    davewalthall:

    PS An even stronger statement of the idiom is:
      return (cond ? a : b);

    Or, as I saw it in a few places while at Microsoft:

    return !!cond;

    Seriously.

  • Gene Wirchenko (cs) in reply to An apprentice
    Anonymous:
    At least it's properly documented! I wouldn't know this method returns a boolean otherwise. And the name authCode is so self-explaining...


    Obviously, it is the Authentic Author Authority Code.  I am not sure whether it is a data value or the program code though.

    Sincerely,

    Gene Wirchenko



  • Enric Naval (cs) in reply to bullseye
    bullseye:

    The Internet:
    What's the deal with these WTF's recently? Clearly, this is fake. We have not run out of real WTF's yet, have we?

    These comments are becoming as tiresome as the "first" posts.

    If it is so outlandish, that it looks fake, then welcome to the world of code maintenance.  As I, and any other developer that works in the real world, can attest to, you see stupid stuff like this frequently.

    Instead of looking like a moron (anonymously) who has never had to work with other people's code, you should sit back and be thankful that you haven't encountered this type of crap in your job.

    (And yes, I am admittedly hostile about this because I have been debugging WTFs all day.  On a side note, I think this site has jaded me to bad programming tactics...)

    Either it is a persistent troll, or some troll made one of this posts, and other have followed suite.

    This kind of WTFs are common. Trust me, Anonymous, I know. I know because I have done them myself, and I had to refactor some of them myself :)

    The sad thing here is seeing how the trolls here have run out of "brillant" trollings, and how they have to resort to bashing again and again the same trollings.

    Errrr, are you sure that I can't mod myself troll?

  • rob_squared (cs) in reply to DWalker59
    DWalker59:
    MikeMontana:
    Yeah, april fools. Too rediculous to be beleived - unless this is the output of some CodeWizard Tool.
     
    Why do so many people have trouble spelling "ridiculous"???


    Because people say it like they say words like redone remade and think an e belongs there.  Now its obviously wrong, because I've never heard of someone diculizing someone.
  • emurphy (cs) in reply to VGR
    VGR:

    private boolean isAdministrator(String authCode)
    {
        return "01".equals(authCode);
    }

    private boolean isFurniture(String productCode)
    {
        return "004".equals(productCode) || "005".equals(productCode);
    }


    Is there a good reason to avoid the following, which reads more like normal English?

    private boolean isAdministrator(String authCode)
    {
        return authCode.equals("01");
    }

    private boolean isFurniture(String productCode)
    {
        return productCode.equals("004") || productCode.equals("005");
    }

  • procyon112 (cs) in reply to rob_squared
    rob_squared:
    DWalker59:
    MikeMontana:
    Yeah, april fools. Too rediculous to be beleived - unless this is the output of some CodeWizard Tool.
     
    Why do so many people have trouble spelling "ridiculous"???


    Because people say it like they say words like redone remade and think an e belongs there.  Now its obviously wrong, because I've never heard of someone diculizing someone.


    We must not go to the same parties.
  • Gene Wirchenko (cs) in reply to rob_squared
    rob_squared:
    DWalker59:
    MikeMontana:
    Yeah, april fools. Too rediculous to be beleived - unless this is the output of some CodeWizard Tool.
     
    Why do so many people have trouble spelling "ridiculous"???


    Because people say it like they say words like redone remade and think an e belongs there.  Now its obviously wrong, because I've never heard of someone diculizing someone.


    Bad reasoning.  You probably have not heard of anyone ading a book either.

    Sincerely,

    Gene Wirchenko

  • bovilexic (unregistered) in reply to mrprogguy
    mrprogguy:

    Can someone please tell  me where that

    <font face="Courier New">if(condition) return something; else return somethingElse;</font>

    idiom came from?

    Why would you need to protect a <font face="Courier New">return</font> with an <font face="Courier New">else</font>?  If the return is exercised, then the other clause is ignored! 

    It's even in the original K&R book on C, written by the guys themselves, and it's no less idiotic coming from someone "authoritative."

    That, to me, is a serious WTF.



    Believe it or not there are some college professors who strictly enforce such garbage.  I experienced this first hand and still do not understand the full rationale behind it.  It was in fact maddening.  This specific professor always made us to do certain things for any bit of code:

    1.  Always put a comment with the performance metric (big O) at the top of every method written.

    2.  Always handle EVERY SINGLE case in a conditional and document it with comments.

    So with #2 you had code that looked like this just so you didn't lose 10% of your assignment grade for not following instructions.  Love this WTF... (and no, not the operation performed, that is made up just to prove the point)

    	// handles all negative numbers and 0
    	if (i <= 0) {
        		i = i * -1.5;
    	}
    	// handles all numbers greater than 0 and less than or equal to 100
    	else if (i <= 100) {
        		i = i * 1.5;
    	}
    	// handles all numbers greater than 100
    	else {
        		// No operation to perform on numbers greater than 100
    	}
  • John Bigboote (cs) in reply to rob_squared
    rob_squared:


     Now its obviously wrong, because I've never heard of someone diculizing someone.


    "Diculize" has actually made its way into the vernacular; it's when somebody passes out and you duct-tape them to the couch and draw on them with magic marker.
  • ParkinT (cs) in reply to DWalker59
    DWalker59:
    MikeMontana:
    Yeah, april fools. Too rediculous to be beleived - unless this is the output of some CodeWizard Tool.
     
    Why do so many people have trouble spelling "ridiculous"???

    Yeah!  That is abserd!

  • Nand (cs) in reply to emurphy
    emurphy:


    Is there a good reason to avoid the following, which reads more like normal English?

    private boolean isAdministrator(String authCode)
    {
        return authCode.equals("01");
    }

    private boolean isFurniture(String productCode)
    {
        return productCode.equals("004") || productCode.equals("005");
    }



    Yes. That code will throw a NullPointerException when productCode == null. You'd have to check that first, or assume that it never happens and pray.


  • kipthegreat (cs) in reply to kiptheretard
    Anonymous:

    kipthegreat:

    Opera is for hippies, gays, and terrorists.  Use Firefox.  It's what the cool kids are using.

    Yeah, screw standardisation and the basis of inter-machine communication, just as long as everyone's a squealing script kiddie and using the same "kewl" browser. Hey, I hear Firefox has the best support for "Web 2.0". lolz.



    Okay, you got me, I was totally serious and you called me on it.  Thanks.  I now view the world in a different light.

    PS: homooperausersayswhat
  • ammoQ (cs)

    The real WTF is that they didn't write

    /**
    * Method is01.
    * @param authCode
    * @return boolean
    */
    private boolean is01(String authCode)
    {
    if (isTrue("01".equals(authCode))) return isTrue(true);
    else return isTrue(false);
    }


    (sorry could not resist, despite the obvious lameness of those IsTrue jokes)

  • kipthegreat (cs) in reply to Alun Jones
    Anonymous:

    davewalthall:

    PS An even stronger statement of the idiom is:
      return (cond ? a : b);

    Or, as I saw it in a few places while at Microsoft:

    return !!cond;

    Seriously.



    Sometimes the !! "operator" makes sense.  In the C++ code where I work, we use COM objects, and "smart pointers", which are actually objects with a pointer and a reference count.  The operators are overloaded so you can use them exactly like pointers.  So "!spObj" returns true if a smart pointer is "null".  So to see if it is NOT null, you use "!!spObj".  It threw me for a loop the first time I saw it, but once you get used to it it makes sense.

    But in the case of a boolean condition like you mentioned... yeah it doesn't make much sense.
  • Tito (unregistered) in reply to Alun Jones

    !!cond is actually a C idiom for ensuring that the value is actually set to "true", where true =1 or -1 as the case may be for the compiler.  Since in C anything nonzero is considered "true" when used in a conditional.  (Because of the whole JNZ asm thing)  However, that can lead to strange situations like having the following two if statements not be equivalent when x=5:

    if (x) // true

    if(x==TRUE) // false  (and yes, this is needlessly verbose, but shouldn't be WRONG)

    So, in order to clean up the possible issue with int variables (and bool's didn't exist until disturbingly recently.. #define int BOOL was normal) using the !!variable would ensure that the variable was ACTUALLY either true(1) or false(0).

Leave a comment on “Refactoring to the Max”

Log In or post as a guest

Replying to comment #:

« Return to Article