• foxyshadis (unregistered)

    I really miss TDWTFs with a page or two of code listings. 10-line wtfs and a pretty description just can't cut it, it's like a gentleman's wtf compared to beasts like the hotel reservation system.

    I wonder if they really did just leave all ten kids to their lonesome for almost two years, believing every progress report ("coming along great!"). Geez.

  • (cs) in reply to Shizzle
    Anonymous:


    On the other hand, the coder was rather clever in not having to use a pesky variable to count over the ArrayList, just use the count of the one you are building instead!  (WTF is an iterator, anyway! or even the addAll method!)



    Better yet, use this extremely sophisticated and hard-to-understand syntax:


    return new ArrayList(getRols());


    If you can put it into a foreach() loop, you can almost always pass it to the ArrayList constructor and get a copy of it.


  • (cs) in reply to foxyshadis
    Anonymous:
    I really miss TDWTFs with a page or two of code listings. 10-line wtfs and a pretty description just can't cut it, it's like a gentleman's wtf compared to beasts like the hotel reservation system.

    I wonder if they really did just leave all ten kids to their lonesome for almost two years, believing every progress report ("coming along great!"). Geez.


    Clearly the developers were not the only inexperienced people on this project....

    -me
  • My Name (unregistered) in reply to foxyshadis

    Anonymous:
    I really miss TDWTFs with a page or two of code listings. 10-line wtfs and a pretty description just can't cut it, it's like a gentleman's wtf compared to beasts like the hotel reservation system.

    You don't see enough bad code at work? Last thing I want is to wade through pages of unreadable crap to get to the WTF. I'll take More Stories and Writeups for 200, Alex.

  • foxyshadis (unregistered) in reply to Patrys
    Anonymous:
    Anonymous:
    It was supposed to be a caching mechanism. Just a mistake in the first != comparison which should have been ==. The idea would be if the roles were already retrieved from the database, don't fetch them again. Unfortunately for everyone the code still worked ... and in testing, with no load on the system, went completely undetected.


    There is no way it could be a planned caching mechanism. For one thing caching needs a static variable and there is clearly a call to getRols in the line you are referring to. Not to mention that each item is pulled off the array, then typecasted from a generic object to it's real base class then it's pushed into another array which could accept it as a generic object as well.

    BTW, if someone tries to advocate this code, he is certainly within the group of the original developers.

    Here's someone who's never implemented a smart caching mechanism in his life, apparently. You realize that the "static variable" can be inside the class and referenced by the function, no? It doesn't have to be inside the calling function!

    But it wasn't, given the juniors were likely around your skill level.
  • Whiskey Tango Foxtrot? Over! (at work) (unregistered) in reply to Oliver Klozoff

    Oliver Klozoff:
    Anonymous:


    On the other hand, the coder was rather clever in not having to use a pesky variable to count over the ArrayList, just use the count of the one you are building instead!  (WTF is an iterator, anyway! or even the addAll method!)



    Better yet, use this extremely sophisticated and hard-to-understand syntax:


    return new ArrayList(getRols());


    If you can put it into a foreach() loop, you can almost always pass it to the ArrayList constructor and get a copy of it.


    So.... What happens when getRols() returns null?

     

    captcha: "foxtrot"!!! I <3 you too, Alex! :D

  • Alexi (unregistered) in reply to My Name
    while (roles.Count < getRols().Count)
    {
    RoleClass role = (RoleClass)getRols().Item[roles.Count];
    roles.Add(role);
    }

    Now, assuming roles.Count this screams WTF
  • Matt (unregistered) in reply to .NET Developer
    Anonymous:
    ...snip

    catch(Exception e) { throw e; }

    hey .Net Developer - please if you are going to rethrow an exception, just call throw, not throw e.

    This will lose the stack trace and you will never see the real eror.

  • (cs) in reply to Someone, Somewhere, outwhere
    Anonymous:

     (translated into php for clarity)


    These words make no sense.
  • (cs) in reply to An apprentice
    Anonymous:
    Alex Papadimoulis:
    public ArrayList GetRoles()
    {
      if (this.getRols() != null)
      {
        ArrayList roles = new ArrayList();
        while (roles.Count < getRols().Count)
        {
          RoleClass role = (RoleClass)getRols().Item[roles.Count];
          roles.Add(role);
        }
        return roles;
      }
      return null;
    }

    Honestly, I fail to see the WTF. Apart from the array being duplicated unnecessarily, that is. And not following capitalization conventions (GetRoles). And funny typos (getRolls?). And the fact that the system lacks any design thought whatsoever. Anything else?

    Mmm.... rolls. Got any sourdough, or potato rolls?

  • Matt (unregistered) in reply to Whiskey Tango Foxtrot? Over! (at work)
    Anonymous:

    So.... What happens when getRols() returns null?

     

    captcha: "foxtrot"!!! I <3 you too, Alex! :D

    this:

    Unhandled Exception: System.ArgumentNullException: Argument cannot be null

    Well in mono anyway (not near a windows box)

  • (cs) in reply to Whiskey Tango Foxtrot? Over! (at work)
    Anonymous:

    So.... What happens when getRols() returns null?



    It never should.  If somebody has no roles, you should be returning the empty set, not null.  That's why we use collections.
  • (cs) in reply to foxyshadis

    Anonymous:
    I really miss TDWTFs with a page or two of code listings. 10-line wtfs and a pretty description just can't cut it, it's like a gentleman's wtf compared to beasts like the hotel reservation system.

    I wonder if they really did just leave all ten kids to their lonesome for almost two years, believing every progress report ("coming along great!"). Geez.

    Perhaps one of them was the Spawn of Paula?

  • l1fel1ne (unregistered)

    A lot of my fellow CS students were making this exact same mistake last term until I pointed it out to them.

  • Yaytay (unregistered) in reply to dasmb
    dasmb:
    Anonymous:

    So.... What happens when getRols() returns null?



    It never should.  If somebody has no roles, you should be returning the empty set, not null.  That's why we use collections.

    Ah yes, but what if the number of roles returned by getrols was to decrease at just the right time?

  • (cs) in reply to Matt

    Anonymous:
    Anonymous:
    ...snip catch(Exception e) { throw e; }
    hey .Net Developer - please if you are going to rethrow an exception, just call throw, not throw e. This will lose the stack trace and you will never see the real eror.

    Not that is a real WTF. Why in the name of all that is pure and holy would you  just throw again!  The whole idea of the try / catch is to gracefully handle errors, or to "throw a more specific error  ie System.ArgumentNullException. But to catch an exception to only throw it again!

  • (cs) in reply to Someone, Somewhere, outwhere
    Anonymous:

    (translated into php for clarity)


    *snickers*

    There are really just two fixes to this:
    1. Remove the GetRols() method and replace it with getRols() wherever it is called. or...
    2. replace it with:

      public ArrayList GetRoles(){
        if(roles == null){//where roles is a class level variable
          roles = getRols();
        }
        return roles;
      }

  • Matt (unregistered) in reply to Kodi
    Kodi:

    Anonymous:
    Anonymous:
    ...snip catch(Exception e) { throw e; }
    hey .Net Developer - please if you are going to rethrow an exception, just call throw, not throw e. This will lose the stack trace and you will never see the real eror.

    Not that is a real WTF. Why in the name of all that is pure and holy would you  just throw again!  The whole idea of the try / catch is to gracefully handle errors, or to "throw a more specific error  ie System.ArgumentNullException. But to catch an exception to only throw it again!

    Agreed, but as the original poster commented - you may want to add logging at this point. I can not see any other reason why you would just rethrow, but if you are, at least do it in a way that so that you can work out where the real error came from.

  • MrGrudge (unregistered) in reply to Sarusa
    Anonymous:
    You know, there's nothing really wrong with using junior programmers as long as you have someone in charge who knows what s/he's doing and can mentor them. That's the real WTF here.


    Assuming that senior person really knows what he is doing as well.  Once I was working as a junior programmer for a senior one who turned out to be less skilled than I was.
  • (cs) in reply to matt
    Anonymous:
    Alex Papadimoulis:

    public ArrayList GetRoles()
    {
      if (this.getRols() != null)
      {
        ArrayList roles = new ArrayList();
        while (roles.Count < getRols().Count)
        {
          RoleClass role = (RoleClass)getRols().Item[roles.Count];
          roles.Add(role);
        }
        return roles;
      }
      return null;
    }


    this isn't really making me scream  wtf.   At least we are seeing code examples again.


    It's not? Let's ignore the whole question of intelligent names for methods and variables, which make this a nightmare to read, and look at the underlying logic: Instead of simply taking every value in getRols(), casting that value to a "RoleClass" (whatever the hell that is), and putting it back into that same datastructure using (at most) one loop, with (at most) one return, he adds an uneccesary conditional check, an uncesarry constructor call, a whole redundant datastructure (double your memory footprint, yee haw!) and a redundant return. And this is a really simple little method.

    Anyone with half a brain should have known better than to call a function with an array if the damn array could be null. You should always do that first, so you don't have to re-implement it for every program you've got to call with that array.
  • You're all stupid (unregistered)

    I'll start by saying this is the first visit to www.thedailywtf.com .

    While this article is what I would consider a "WTF?", the comments on here are by far worse. Don't criticize code you can't even read properly. My lord.

    In 62 comments I think there there were 4 correct interpretations of the code. Still, none of the non-obvious aspects were touched, only the performance impact. What about the order of returned result sets from getRols().Item[roles.Count]? SQL does not guarantee order of result set, so there's no guarantee you'll get every record without duplicates. Even with an order by clause, if a row is inserted while inside the loop your order is hosed, and data integrity compromised.

    On the importance chain Integrity > Performance  always. If it takes 10 seconds to log on that sucks but if it does not log me on because it keeps skipping a record, that's "WTF".

    I'll end by saying nice website... FireBug logged 4300 javascript errors as I typed this message(this.document.ftb has no properties) . That's my final WTF.

  • NT (unregistered) in reply to TankerJoe

    I have to admit, there are so many WTF's in that single function, which is only a measly 15 lines of code long, that it took me a few minutes just to catalogue them all.

    First, unless I am mistaken, the fact that the function exists, seems like the biggest WTF. getRols() returns the exact same ArrayList as GetRoles() does, thus making GetRoles() unnecessary except for the fact that GetRoles() is a far better choice for a function name, thus bringing us to the next WTF, which is the name of getRols(). It absolutely drives me mad when programmers abbreviate words unnecessarily or just drop letters for no apparent reason.

    Now assuming that GetRoles() actually served a purpose (which it doesn't) then, as others have correctly pointed out, the function seems to be written for the worst possible performance. Perhaps the programmers took it as a challenge to see which one of them could write the slowest function that did nothing in 15 lines or less. Calling getRols() in the conditional causes that function to be evaluated for each iteration of the while loop. Calling getRols() in the defitition of the loop causes getRoles() to be evaluated yet again for each iteration of the while loop. That means even if the getRols() procedure ran in linear time, the performance of GetRoles() would be 2n^2 best case! A better practice would be to call getRols() one time before the loop, store the arrayList it returns locally, store the ArrayList.Count into an integer locally, use that integer in the conditional of the while loop, and use the ArrayList Item array in the definition of the loop. This would yeild linear complexity for GetRoles(), if there was any purpose for GetRoles() in the first place (which as I mentioned there is not).

    And as someone above pointed out, regardless of whether getRols hits the database or not, the above mentioned is still the case and its still a major WTF because every time getRols() is called unnecessarily it pushes a new instances of that function onto the stack, allocating memory and stealing cpu time unnecessarily. The fact that it does hit the database magnifies the problem because then it gets to steal time away resources from the machine the database resides on as well as eat network bandwidth.

  • Shizzle (unregistered) in reply to You're all stupid
    Anonymous:

    I'll start by saying this is the first visit to www.thedailywtf.com .

    While this article is what I would consider a "WTF?", the comments on here are by far worse. Don't criticize code you can't even read properly. My lord.

    In 62 comments I think there there were 4 correct interpretations of the code. Still, none of the non-obvious aspects were touched, only the performance impact. What about the order of returned result sets from getRols().Item[roles.Count]? SQL does not guarantee order of result set, so there's no guarantee you'll get every record without duplicates. Even with an order by clause, if a row is inserted while inside the loop your order is hosed, and data integrity compromised.

    On the importance chain Integrity > Performance  always. If it takes 10 seconds to log on that sucks but if it does not log me on because it keeps skipping a record, that's "WTF".

    I'll end by saying nice website... FireBug logged 4300 javascript errors as I typed this message(this.document.ftb has no properties) . That's my final WTF.


    Next time you think of coming here, go to www.thedailySTFU.com instead.  I hate your attitude. Thanks in advance.

  • gRegor (unregistered) in reply to OneMHz
    OneMHz:
    Mmm.... rolls. Got any sourdough, or potato rolls?

    Darn, someone beat me to it!  I was going to comment about how hungry this WTF made me. :-]
  • (cs) in reply to You're all stupid
    Anonymous:

    I'll start by saying this is the first visit to www.thedailywtf.com .

    While this article is what I would consider a "WTF?", the comments on here are by far worse. Don't criticize code you can't even read properly. My lord.

    In 62 comments I think there there were 4 correct interpretations of the code. Still, none of the non-obvious aspects were touched, only the performance impact. What about the order of returned result sets from getRols().Item[roles.Count]? SQL does not guarantee order of result set, so there's no guarantee you'll get every record without duplicates. Even with an order by clause, if a row is inserted while inside the loop your order is hosed, and data integrity compromised.

    On the importance chain Integrity > Performance  always. If it takes 10 seconds to log on that sucks but if it does not log me on because it keeps skipping a record, that's "WTF".

    I'll end by saying nice website... FireBug logged 4300 javascript errors as I typed this message(this.document.ftb has no properties) . That's my final WTF.



    As you are new here you should be properly introduced to the forum software, Community Server 2.0.

    Had you been around for Community Server 1.0 you would be quite familiar with the phrase "The real WTF is the forum software".  While 2.0 seems to be 'better?' it does come with it's own bag of WTFs.

    And you should also know that no matter how bad the WTF there is somebody that will try to defend or rationalize it.
  • Just Imagine (unregistered)

    Just imagine if you replaced getRols() with getPaula()?

    Why, I bet it would be Enterprise Visual Web 2.0 XP SP ISO 9001 complient with that change alone!

  • StupidPeopleTrick (unregistered) in reply to Just Imagine

    Oh common guys, maybe the application was written to be a DB DOS application..... or not...

    I think this is a commone jr. dev issue.  As the story reads, they let the jr. devs go.  The correct method to handle this is to hire the sr. dev on and do code reviews.  By taking the route this company took, no one benifits long term.  I call management WTF.

    - SPT

  • You're all stupid (unregistered) in reply to smbell

    I was being deliberatly jerky and figued it to be a good end note. Truth be told, I'm really fond of this inline rich text editor and the comment system is very nice. I write TONS of raw Javascript for Ajax and DHTML so I know how hard it is to catch all JS bugs which tend to be trivial. I could hop on a horse and say why didn't you use firebug to test in the first place, but I was only trying to be funny. (BTW firebug is completely awesome in the highest of high senses).

    The content of the articles is very good and I do belive I'll become a more regular visitor. And yes, I'll lose the "attitude".  ; - )

    I just thought it was funny how many people said, "OMG it's always null what a bad programmer" or "here's a better (bloated) 25 line way of doing this extremely simple and redundant function".  It had humor beyond the article itself.


  • Shizzle (unregistered) in reply to You're all stupid
    Anonymous:
    I was being deliberatly jerky and figued it to be a good end note. Truth be told, I'm really fond of this inline rich text editor and the comment system is very nice. I write TONS of raw Javascript for Ajax and DHTML so I know how hard it is to catch all JS bugs which tend to be trivial. I could hop on a horse and say why didn't you use firebug to test in the first place, but I was only trying to be funny. (BTW firebug is completely awesome in the highest of high senses).

    The content of the articles is very good and I do belive I'll become a more regular visitor. And yes, I'll lose the "attitude".  ; - )

    I just thought it was funny how many people said, "OMG it's always null what a bad programmer" or "here's a better (bloated) 25 line way of doing this extremely simple and redundant function".  It had humor beyond the article itself.


    Don't hate the Coder, hate the Code!
  • Anon (unregistered)

    Sounds like Alex has been reading ActsofGord.com

  • Yaytay (unregistered) in reply to You're all stupid

    Anonymous:

    On the importance chain Integrity > Performance  always.

    Not always.

    Very rare for something to be "always" in this business.

    Sometimes a quick rough idea is good enough.

    But nearly always, I'd have to give you that.

  • Anon (unregistered)

    The Rock says know your role, and shut your damn mouth.

  • (cs) in reply to NT
    Anonymous:
    That means even if the getRols() procedure ran in linear time, the performance of GetRoles() would be 2n^2 best case!


    I came up with 2n+2.... It looks pretty linear to me...
  • (cs)

    <FONT size=4>Roles on the floor laughing</FONT>

  • (cs) in reply to Oliver Klozoff
    Oliver Klozoff:
    Anonymous:


    On the other hand, the coder was rather clever in not having to use a pesky variable to count over the ArrayList, just use the count of the one you are building instead!  (WTF is an iterator, anyway! or even the addAll method!)



    Better yet, use this extremely sophisticated and hard-to-understand syntax:


    return new ArrayList(getRols());


    If you can put it into a foreach() loop, you can almost always pass it to the ArrayList constructor and get a copy of it.

    Or even the following (using Java), which would avoid one redundant array copy operation.

        public List getRoles() {
            List roles = getRolesFromDB();
            if (roles == null) {
                return null;
            }
            return Collections.unmodifiableList(roles);
        }

  • Patrys (unregistered) in reply to foxyshadis
    Anonymous:
    Anonymous:
    Anonymous:
    It was supposed to be a caching mechanism. Just a mistake in the first != comparison which should have been ==. The idea would be if the roles were already retrieved from the database, don't fetch them again. Unfortunately for everyone the code still worked ... and in testing, with no load on the system, went completely undetected.


    There is no way it could be a planned caching mechanism. For one thing caching needs a static variable and there is clearly a call to getRols in the line you are referring to. Not to mention that each item is pulled off the array, then typecasted from a generic object to it's real base class then it's pushed into another array which could accept it as a generic object as well.

    BTW, if someone tries to advocate this code, he is certainly within the group of the original developers.

    Here's someone who's never implemented a smart caching mechanism in his life, apparently. You realize that the "static variable" can be inside the class and referenced by the function, no? It doesn't have to be inside the calling function!

    But it wasn't, given the juniors were likely around your skill level.


    Actually in any sane programming language the variable HAS TO be inside the class to be called "static". And you obvously lack the skill of reading quotations that posts respond to.

    Not to mention that you have a weird sense of caching implementation. Had this be a caching function, it would do something along the lines of "static foo = null; if (foo == null) foo = getRols(); return foo". Nothing even close to the crap posted above.
  • Adrian (unregistered) in reply to matt

    Ok GetRols is a call to a database, so that is two db hits for each role + 1 to retrieve a list of roles.  If that does not make you scream I don't know wtf will.

    CAPTCHA : Genius.

  • Tony Morris (unregistered) in reply to WeatherGod
    WeatherGod:
    Correct me if I am wrong, but wouldn't I get the same behavior if I just replaced all calls to GetRoles() with calls to getRols()?


    You're wrong. ArrayList contains functions (yes functions) that are not referentially transparent. This means that contract implementation identity ("newness" in Java/C#) is significant, hence the need to create a new ArrayList. If the type contained operations that were all referentially transparent, you would not care about implementation identity.

    You can observe the effect of giving the authority to design a language - to people who are incompetent at the task (common euphemism: expert groups) - by observing some of the atrocities in both Java and .NET. Specifically, the "hiding of constructors" behind "factory methods" since it exposes less to the client (no implicit identity) and the type is referentially transparent. Trivia: why was java.lang.Integer#valueOf(int) introduced in 1.5 when Integer#Integer(int) already existed? FWIW, I no longer work on the 1.5 implementation.

    It's Programming Language Theory 101 stuff, but it's ignored in the industry anyway.
  • (cs)
    Anonymous:
    snoofle:
    GoatCheez:
    For all of you that are missing why this is SO HORRIBLY DOWNRIGHT AWFULLY HORRENDOUS, I'll explaing... although I probably shouldn't since you should know better anyway!!!

    First, I'll just note that it looks like GetRoles was created to retrieve the roles without hitting the database. (If it wasn't, then it's a COMPLETELY USELESS function.)

    Now...

    The first conditional (that means an if statement) calls getRols. getRols it is pointed out hits the database to retrieve the information it returns. The conditional however only checks that the return value is not null, indicating that the call succeded and was able to return some sort of information (an arraylist).

    Next, we create the array list that our "non-database-hitting-function" will return.

    Now, we start a while loop, saying that until our return list is the size of the database list, we do things (see below). I believe every iteration of this would hit the database again, as I don't think the count will be cached by the compiler in an attempt to optimize the loop. Don't quote me on that though, it could vary greatly depending on the compiler, and other things as well.... Skepticism leads me to believe though that this will in fact hit the database for every iteration to check against the count.

    Now, we are in the loop.... in here, we HIT THE DATABASE AGAIN! This time, it's to index a role in the list that is returned, so we can set our corresponding item in our list to that role.

    Finally, the new list is returned... only if they had known though that

    public ArrayList GetRoles()
    {
    return getRols();
    }

    was all the code they needed for this useless function. Well, they should have at least seen that all their code was doing was the above.... This is definitely a good WTF today lol.

    So to recap, let's say that there were 7 roles. Calling this function would result in hitting the database...

    initial check
      while check 0 == true
          general hit
      while check 1 == true
          general hit
       while check 2 == true
          general hit
      while check 3 == true
          general hit
       while check 4 == true
          general hit
      while check 5 == true
          general hit
       while check 6 == true
          general hit
      while check 7 == false

    16 times... wow... that's REALLY bad... REALLY REALLY bad. Are you sure these were junior developers and were not monkeys?

    ;-P

    You, Sir, have sullied the good name of Monkey!



    I'm fairly sure that the monkeys would have gotten this one right.

    http://www.newtechusa.com/ppi/main.asp


    There are basically three types of monkey programmers.

    1) the fun little chimps. - they do all the ( happy ) banging on the keyboard.
    2) the huge great apes. - they handle the ( serious ) oversight and governance.
    3) the barrel *of* monkey(tm). - originally wooden, they provide the "out of the box" inspiration - and are often involved in marketing 

    Given these distinct and necessary concerns that makes up any good development team - it's not far fetched, that this code was truly Built-With-Pride by monkeys.

  • Ishai (unregistered)

    I am sorry to disagree. this is not a WTF. this is definitly a OMGWWTTO

    (oh my god, what were they thinking of?!)

  • Miscelaneous Man (unregistered) in reply to Luke

    I'm right with you buddy. Except the person I'm under has 5 years on me.

  • (cs) in reply to Tony Morris
    Anonymous:
    WeatherGod:
    Correct me if I am wrong, but wouldn't I get the same behavior if I just replaced all calls to GetRoles() with calls to getRols()?


    You're wrong. ArrayList contains functions (yes functions) that are not referentially transparent. This means that contract implementation identity ("newness" in Java/C#) is significant, hence the need to create a new ArrayList. If the type contained operations that were all referentially transparent, you would not care about implementation identity.

    You can observe the effect of giving the authority to design a language - to people who are incompetent at the task (common euphemism: expert groups) - by observing some of the atrocities in both Java and .NET. Specifically, the "hiding of constructors" behind "factory methods" since it exposes less to the client (no implicit identity) and the type is referentially transparent. Trivia: why was java.lang.Integer#valueOf(int) introduced in 1.5 when Integer#Integer(int) already existed? FWIW, I no longer work on the 1.5 implementation.

    It's Programming Language Theory 101 stuff, but it's ignored in the industry anyway.


    Uh-huh.  I am glad I stick with C++ most of the time.  I just picked up a Java book the other day, and just when I thought I understood the concepts, all of this "factory" stuff came up.  Thanks for clearing that up.

  • nFec (unregistered)

    Uhh, thats nice!
    In fact, why not let getRows() create a whole new ArrayList for every row in the database?
    Its 2006 god damn it! We got enough space and hertz to do this!
    Just do everything step by step. That creates roads over time.
    Anyway...
    As i said before, i should SO get a well paid job.
    Even if im not the wiz of wizards, id so gonna kick their ass.

    And to honor the day; this posts captcha.equals("craptastic") == true.

  • (cs) in reply to Someone, Somewhere, outwhere
    Anonymous:
    every call to getRols() performs a multiple-row-resultant query on the database

    so let's expand this function (translated into php for clarity), and include what it's calling


    Oh, my, yes. Translating it into php certainly made it clearer...

    ...kinda like cleaning a window with mud.
  • (cs) in reply to Sarusa
    Anonymous:
    You know, there's nothing really wrong with using junior programmers as long as you have someone in charge who knows what s/he's doing and can mentor them. That's the real WTF here.


    Well said.
  • (cs) in reply to gadgetarms
    gadgetarms:
    This isn't actually as bad as it may seem.  getRols()  is probably a private getter method wrapping an instance variable, while GetRoles is the public equivalent and does nothing but clone the Roles returned by getRols().  Most likely, this is an attempt to keep external classes from adding/removing items from the Roles list (since ArrayList is not immutable).  Although the choice of method names and the fact that they didn't use roles.clone() leaves something to be desired, I've seen much worse.  Of course if I am wrong and getRols() makes a database call, then this code really sucks.
    Even if you were right, it'd suck anyway. The repeated calls to getRols() needlessly suck processor time.

    And you've heard of java.util.Collections.unmodifiableList(), right? The WTFery goes on and on...
  • NZ'er (unregistered) in reply to Keith Gaughan

    <off topic>
    Someone from opera obviously reads this forum, they have now introduced screen women to the sidebar to compete with foosball girl and beanbag girl!!!!   Pretty pathetic attempt but hey shows someone is listning to the bable that goes on here!
    </off topic>


  • (cs) in reply to little whipper snapper

    Anonymous:
    Hey now. Us junior devs are just trying. Well, some of us. (Besides... the wtf is not *that bad* as long as the # of roles are <= 1.) //runs away... quickly

     

    They certainly were trying...the company's patience.

  • (cs)

    The real WTF is why Sumo Lounge girl isn't sitting on my lap instead.

  • Jonah (unregistered) in reply to Tony Morris

    Code like this is ugly, but it doesn't surprise me. I've been taking some CS classes at a state school near to where I live. In my experience, students can get away with writing code like this, and they are never corrected as long as their programs pass all the test cases. You can write horribly ugly and inneficient code, and still get an A as long as your program passes all the test cases and your code includes a sufficient percentage of comments.

    I think the algorithm used to grade programming assignments must look something like this:

    
    char grade(Program program)
    {
      if (!program.compile())
      {
        return 'F';
      }
      else
      {
        float percentPassed = program.runTestCases();
        float percentComments = program.percentComments();
    
    if (percentPassed == 100)
    {
      if (percentComments > GOOD_COMMENT_PERCENTAGE)
        return 'A';
      else
        return 'B';
    }
    else if (percentPassed > OK_PASS_PERCENTAGE)
    {
      if (percentComments > GOOD_COMMENT_PERCENTAGE)
        return 'B';
      else
        return 'C';
    }
    else
    {
      return 'D';
    }
    

    } }

Leave a comment on “The Juniors' Whopper”

Log In or post as a guest

Replying to comment #:

« Return to Article