These Go To Fourteen

« Return to Article
  • Cheatah 2008-01-07 08:02
    Company policy:

    - never use collections
    - never use generics
  • snoofle 2008-01-07 08:02
    This one's hard to call - with annonymization, "one"..."fourteen" might have been meaningful variable names, in which case a lot of it would make more sense. Of course, brute-forcing it in the middle of a loop is a WTF in and of itself...

    Note from Alex: Only changes to the originally submitted code was the "snipping" and some formatting.
  • sir_flexalot 2008-01-07 08:06
    Now that's a WTF! I love that there's an explanation about how this is "elegant"... I'd say it's more like elephant s***.
  • Blain 2008-01-07 08:12
    I do not understand the solution. I do not understand the problem they're trying to solve. I do not understand what's "elegant". I think I have reached Nirvana...
  • Licky Lindsay 2008-01-07 08:14
    Shenanigans. There is no way this code is real.

  • Friedrich 2008-01-07 08:15
    "//ED: By the setter of the ninth attribute, the argument name was
    // understandably changed to entry. All those numbers are tiring
    // to write!
    public void setFourteen( String entry)
    {
    this.fourteen=entry;
    }
    "

    That's understandably ;-(

    Regards
    Friedrich
  • Rohan Prabhu 2008-01-07 08:19
    when i see people like this getting hired.. i get assurance of a bright career...
  • Hans 2008-01-07 08:23
    Is it very hard to declare a dynamically sized array of strings in java? I realize doing so would break the beautiful encapsulation present in this classy design, but that would only really be a problem if you ever wanted to use a different type of string. Somehow I think the benefits of that approach would outweigh the inherent risk.

    Or if you really, really want a class and be enterprisey about it, just do

    class ListBean {
    public:
    enum numbers { one, two, three, ..., fourteen };

    void set (numbers Number, string Value);
    string get (numbers Number) const;

    private:
    vector<string> Values;
    }

    (yes, this is C++ - I don't know java well enough). Far less code, and an API that is bad enough that it should make all those enterprise-clowns cry with happiness.


  • MAV 2008-01-07 08:29
    But sir! We have to have 15 items or all our online transactions will grind to a halt!

    15 ITEMS?!?! OH GOD! WHEN WILL PEOPLE LEARN?! IF ONLY THEY'D HAVE MADE IT WITH 15 ITEMS!
  • Erik 2008-01-07 08:29
    Right... but this one goes to eleven.

    </spinal tap>
  • Csaboka 2008-01-07 08:32
    Hooray!

    Finally, we see someone who has mastered the FOR-CASE paradigm. Actually, he managed to mix it with the OO paradigm, making a new paradigm altogether. All we have to do is name the new paradigm and teach them to the new generations of programmers!
  • Cheatah 2008-01-07 08:33

    package com.initrodeglobal.util.presentation;

    public class FourteenEnterPriseListBean extends ThirteenEnterPriseListBean
    {
    private string fourteen;

    public FourteenEnterPriseListBean (String one, String two, String three,
    String four, String five, String six,
    String seven, String eight, String nine,
    String ten,String eleven, String twelve,
    String thirteen , String fourteen)
    {
    super (one, two, three, four, five, six, seven,
    eight, nine, ten, eleven, twelve, thirteen);
    this.fourteen = fourteen;
    }

    public void setFourteen (String entry)
    {
    this.fourteen = entry;
    }

    public String getFourteen ()
    {
    return this.fourteen;
    }
    }
  • Case 2008-01-07 08:33
    The next-worst part is that they actually typed in all those getters and setters... any half decent editor can do it for you.
  • Carra 2008-01-07 08:35
    Wru!

    Euh,
    public ListBean(ArrayList params)
    {
    for (int a=1;a<=params.size();a++) switch (a)
    {
    case 1 : if (params.get(0) != null)
    this.one=params.get(0).toString();
    break;
    case 2 : if (params.get(1) != null)
    this.two=params.get(1).toString();
    break;

    ... snip ...

    case 14 : if (params.get(13) != null)
    this.fourteen=params.get(13).toString();
    break;
    }
    }
    WTF, this just feels so wrong!
  • Tassos 2008-01-07 08:36
    Nope. Won't work, constructors aren't inherited.
  • java.util.collection 2008-01-07 08:39
    Hans:
    Is it very hard to declare a dynamically sized array of strings in java?


    Collection<String> variablySizedStringArrayForHans = new ArrayList<String>();

    and then just .add() any string to it that you want. This provides a nice amount of polymorphism, since the collection interface allows enough functions to do anything, and you can choose you implementation (lists, sets etc..)

    or for kicks, if you want your values accesable by a lable, use a map instead of a collection
  • java.util.collection 2008-01-07 08:42
    Tassos:
    Nope. Won't work, constructors aren't inherited.


    if you are referring to cheatah, yes it will, he is calling super(13 args), not this(13 args), which wouldnt work. He is just calling the 13 arg constructor of the superclass, which does have that ctr
  • java.util.collection 2008-01-07 08:43
    Tassos:
    Nope. Won't work, constructors aren't inherited.


    if you are referring to cheatah, yes it will, he is calling super(13 args), not this(13 args), which wouldnt work. He is just calling the 13 arg constructor of the superclass, which does have that ctr
  • ObiWayneKenobi 2008-01-07 08:45
    And THIS is exactly why programmers should be hired/promoted based on merit, not seniority. I've seen more than my share of companies where the lead/senior developer only had that position because he was with the company for years (or was its first programmer, or whatever), so had seniority but didn't know his ass from a hole in the ground or how to properly write software. Yet bozos like these constantly are in charge of better developers, and make asinine decisions like we see here.
  • ThePants999 2008-01-07 08:50
    Tassos:
    Nope. Won't work, constructors aren't inherited.

    I'm guessing you're referring to the fact that FourteenEnterPriseListBean won't have constructors for one through thirteen list items. That's okay - you'd just instantiate a ThirteenEnterPriseListBean (or other appropriate class) instead!
  • Aicho 2008-01-07 08:51
    Does this make anyone else's stomach hurt? They import ArrayList and are too thick to use it? If that doesn't scream WTF than I don't know what does :-D
  • John 2008-01-07 08:54
    Err, its the new generation of programmers that come up with this crap.
  • dkf 2008-01-07 08:57
    "This way, we don't have to use the real object and can save memory."
    Holy crud! That leading comment is by far the scariest bit of the whole WTF, especially with those constructors...
  • hc 2008-01-07 09:03
    Well, obviously this class should implement Iterable<String>. How silly of them, now their memory efficient list can't be iterated!
  • nobody 2008-01-07 09:08
    It is clear that they intend to upgrade to HEX in the near future.
  • Matt 2008-01-07 09:12
    Csaboka:
    Hooray!

    Finally, we see someone who has mastered the FOR-CASE paradigm. Actually, he managed to mix it with the OO paradigm, making a new paradigm altogether. All we have to do is name the new paradigm and teach them to the new generations of programmers!


    FOR CASE OO List. You could even make a cool anagram out of it: Socrates Folio.
  • Emphyrio 2008-01-07 09:18
    Perhaps they just wanted a holder for a fixed number of related strings (like a Python tuple), without having to write
    ArrayList<String> a = new ArrayList<String>();
    
    a.add(one);
    a.add(two);
    a.add(three);
    ...

    which is, after all, rather verbose. Of course, in that case they could have just used
    a = new String[] { one, two, three, ... };


  • Zygo 2008-01-07 09:20
      public void setTwo( String two)
    
    {
    this.two=two;
    }


    I expected to see

      public void setEight( String nine)
    
    {
    this.seven=eight;
    }


    Happily there is no possibility of the compiler detecting this error since the "this" is implied everywhere that the compiler could have used its absence to be helpful.

    Wow, that's a painful aggregation of pronouns for this early on a Monday morning. :-P
  • mightybaldking 2008-01-07 09:20
    Cheatah:

    package com.initrodeglobal.util.presentation;

    public class FourteenEnterPriseListBean extends ThirteenEnterPriseListBean
    {
    private string fourteen;

    public FourteenEnterPriseListBean (String one, String two, String three,
    String four, String five, String six,
    String seven, String eight, String nine,
    String ten,String eleven, String twelve,
    String thirteen , String fourteen)
    {
    super (one, two, three, four, five, six, seven,
    eight, nine, ten, eleven, twelve, thirteen);
    this.fourteen = fourteen;
    }

    public void setFourteen (String entry)
    {
    this.fourteen = entry;
    }

    public String getFourteen ()
    {
    return this.fourteen;
    }
    }


    That is just sheer elegance!
  • Grovesy 2008-01-07 09:44
    Csaboka:
    Hooray!

    Finally, we see someone who has mastered the FOR-CASE paradigm. Actually, he managed to mix it with the OO paradigm, making a new paradigm altogether. All we have to do is name the new paradigm and teach them to the new generations of programmers!


    I name it the For Object Orientated Case ExtenDed Paradigm

    Shortened to The FOOC paradigm, and rather aptly phonetically pronounced “Fooc-ed Paradigm”
  • Bosshog 2008-01-07 09:50
    This code is so elegant, it makes me want to poke out my own eyes with a fourteen pronged fork.
  • pitchingchris 2008-01-07 09:53
    Erik:
    Right... but this one goes to eleven.

    </spinal tap>


    Made me cringe just reading this comment. I had a spinal tap when I was 3 due to meningitis. Guess thats why I have a phobia against needles.
  • hc 2008-01-07 09:54
    Or
    Arrays.asList(one, two, three)
  • Or CASE-FOO 2008-01-07 10:02
    Csaboka:
    Hooray!

    Finally, we see someone who has mastered the FOR-CASE paradigm. Actually, he managed to mix it with the OO paradigm, making a new paradigm altogether. All we have to do is name the new paradigm and teach them to the new generations of programmers!

    I nominate FOOR-CASE.
  • Quiark 2008-01-07 10:31
    I always wondered how to store multiple values in a class. Thanks for this tip !



    :D
  • Some 25th Grader 2008-01-07 10:39
    This code reminds me of a classmate of mine back in 8th grade. In English class, he rose his hand to ask the teacher, "What eloquent mean?" It took everything in me not to serve detention for laughing at the sweet sweet irony that had just unfolded before my eyes.
  • Spectre 2008-01-07 10:56
    Csaboka:
    Hooray!

    Finally, we see someone who has mastered the FOR-CASE paradigm. Actually, he managed to mix it with the OO paradigm, making a new paradigm altogether. All we have to do is name the new paradigm and teach them to the new generations of programmers!


    Maybe FOR-CASE-OOooohh...
  • Sam 2008-01-07 10:57
    Bosshog:
    This code is so elegant, it makes me want to poke out my own eyes with a fourteen pronged fork.


    Wouldn't it be safer to use a fifteen pronged fork?
  • bd 2008-01-07 11:01
    Pay special attention to the constructor that takes ArrayList. If you squint a bit, it looks like a Duff's device. Or in this case, Dufus' device.
  • dkf 2008-01-07 11:10
    bd:
    Pay special attention to the constructor that takes ArrayList. If you squint a bit, it looks like a Duff's device. Or in this case, Dufus' device.
    Heh! I like that name.
  • OperatorBastardusInfernalis 2008-01-07 11:21
    I wouldn't touch this with a fourteen foot pole...

    I'd need the fifteen foot pole to touch this.
  • TM 2008-01-07 11:48
    I just died a little inside...
  • Andrew 2008-01-07 12:36
    A dynamically-sized array is a Vector.
  • Zylon 2008-01-07 12:39
    pitchingchris:
    Erik:
    Right... but this one goes to eleven.

    </spinal tap>


    Made me cringe just reading this comment. I had a spinal tap when I was 3 due to meningitis. Guess thats why I have a phobia against needles.

    I do hope you realize he was referring to the movie, not the procedure.
  • The Outlaw Programmer 2008-01-07 12:50
    I'm having a hard time believing this one. I could understand a junior programmer writing, say, the first 20 lines of code. Once they hit the constructor that takes the ArrayList, though, I'm pretty sure everyone would have realized that "hey, the ArrayList is the exact data structure I'm trying to represent!" and stopped immediately.

    My only guess is that this constructor was actually written later by a more experienced developer that was too lazy to actually refactor the code properly. Maybe, for some reason, they were forced to keep this object around and got sick of calling a 14 argument constructor. Still doesn't make fetching the values any easier though...

    On second thought, no, there's no way that this code is real. Must be some kind of bad dream that I'm having...
  • yoz-y 2008-01-07 12:51
    The real WTF is that they didn't use the automated Getters and Setters generation
  • Enterprise Architect 2008-01-07 12:54
    I find this class very useful, but it has too many functions, which makes it slow. My improved version (in C++, also for speed):

    #include <string>

    template <int i>
    class EnterpriseListBean : public EnterpriseListBean<i-1> {
    private:
    std::string value;
    public:
    virtual std::string get(int x) {
    return x == i ? value : EnterpriseListBean<i-1>::get(x);
    }
    virtual void set(int x, std::string value) {
    if(x == i)
    this->value = value;
    else
    EnterpriseListBean<i-1>::set(x, value);
    }
    };

    template<>
    class EnterpriseListBean<0> {
    private:
    std::string value;
    public:
    struct NinjaStar {
    const char *what() {
    return "YOUR HEAD ASSPLODE";
    }
    };
    virtual std::string get(int i) {
    throw NinjaStar();
    }
    virtual void set(int i, std::string value) {
    throw NinjaStar();
    }
    };

    typedef EnterpriseListBean<0> GenericEnterpriseListBean;
  • tray 2008-01-07 12:58
    This is the FOURTEEN-CASE paradigm, not the FOR-CASE one.
    You should know that.
  • SenorLapiz 2008-01-07 12:59
    It's the FOURTEEN-CASE paradigm!
  • Leak 2008-01-07 13:25
    OperatorBastardusInfernalis:
    I'd need the fifteen foot pole to touch this.

    HAMMER TIME!
  • Will 2008-01-07 13:28
    I don't get it... what's its purpose? It's not just a List<String> equivalent hard coded to fourteen elements (in an incredibly retarded way) is it?
  • Brother Laz 2008-01-07 13:43
    It is their business secret. While the competition is stuck at 10, you just turn it up to 14!

    This must have been the result of statistics. Perhaps someone noticed that 10 whatevers weren't enough to do whatever they wanted to do, and did some calculations and realised that they wouldn't need more than 13 whatevers in the company's lifetime, give or take error margin X. To be on the safe side, the business reqs contained the line 'next version must have 14 whatevers' and the programmer duly implemented 14 whatevers.
  • circuit_breaker 2008-01-07 13:48
    public class PaulaBean {

    public Brillant() {
    // stuff
    }

    }
  • Gonzalo 2008-01-07 13:56
    I now understand.. this is the other half of the brain that Paula has missing...
  • Steeldragon 2008-01-07 14:01
    Gonzalo:
    I now understand.. this is the other half of the brain that Paula has missing...

    quite possibly
  • Lysis 2008-01-07 14:09
    Rohan Prabhu:
    when i see people like this getting hired.. i get assurance of a bright career...


    Ummm actually, since management rarely has a clue, if he was convincing on how brilliant it is then he probably got a raise and promotion for "thinking outside the box." That term is pseudo-code for "I'm a management asshole."
  • kaamoss 2008-01-07 14:11
    Obligatory Spinal Tap Quote: "But this one, goes to eleven!"
  • dpm 2008-01-07 14:14
    Brother Laz:
    To be on the safe side, the business reqs contained the line 'next version must have 14 whatevers' and the programmer duly implemented 14 whatevers.


    Nice analysis, but you misspelled "dully". HTH!
  • Anonymous 2008-01-07 14:19
    Lysis:
    Rohan Prabhu:
    when i see people like this getting hired.. i get assurance of a bright career...


    Ummm actually, since management rarely has a clue, if he was convincing on how brilliant it is then he probably got a raise and promotion for "thinking outside the box." That term is pseudo-code for "I'm a management asshole."

    Remember, it's "brillant".
  • dcardani 2008-01-07 14:19
    Csaboka:
    Hooray!

    Finally, we see someone who has mastered the FOR-CASE paradigm. Actually, he managed to mix it with the OO paradigm, making a new paradigm altogether. All we have to do is name the new paradigm and teach them to the new generations of programmers!


    It's not just a FOR-CASE paradigm. This is an all-new extension - the FOR-CASE-IF paradigm. I'm not sure we're fully appreciating it here!
  • brazzy 2008-01-07 14:24
    Andrew:
    A dynamically-sized array is a Vector.

    Only if you live in the last millenium. For everyone else, it's an ArrayList, or just a List.
  • VGR 2008-01-07 14:31
    The Outlaw Programmer:
    I'm having a hard time believing this one. I could understand a junior programmer writing, say, the first 20 lines of code. Once they hit the constructor that takes the ArrayList, though, I'm pretty sure everyone would have realized that "hey, the ArrayList is the exact data structure I'm trying to represent!" and stopped immediately.

    My only guess is that this constructor was actually written later by a more experienced developer that was too lazy to actually refactor the code properly. Maybe, for some reason, they were forced to keep this object around and got sick of calling a 14 argument constructor. Still doesn't make fetching the values any easier though...

    On second thought, no, there's no way that this code is real. Must be some kind of bad dream that I'm having...

    Oh, it's real. The world is filled with people who are certain they can manage memory better than Java can. In the last ten years, I've worked with at least eight of them. Why Java and Java alone gets this treatment, I'm not entirely sure. (I have some guesses though.)

    One thing is clear: the golden rule of premature optimization was not a factor here. The optimizing programmer didn't even try ArrayList before concluding that a more "memory efficient" version was needed.

    Whenever I see an attempt to supplant a standard library class, I ask for justification in the form of reproducible benchmarks in the code review.
  • kid_wonder 2008-01-07 16:07
    Source -> Generate Getters and Setters

    Duh.
  • Unomi 2008-01-07 16:39
    Brother Laz:
    It is their business secret. While the competition is stuck at 10, you just turn it up to 14!

    This must have been the result of statistics. Perhaps someone noticed that 10 whatevers weren't enough to do whatever they wanted to do, and did some calculations and realised that they wouldn't need more than 13 whatevers in the company's lifetime, give or take error margin X. To be on the safe side, the business reqs contained the line 'next version must have 14 whatevers' and the programmer duly implemented 14 whatevers.


    If that is the (for-) case, than they are just one-third there, since the answer to all questions is 42....

    - Unomi -
  • Mario 2008-01-07 16:47
    for (int a=1;a<=params.size();a++) switch (a)

    Aaaaaaaah!
  • Self Aware 2008-01-07 16:47
    I don't see what the big deal is. This bean can easily be fixed by adding "sie" to the end of all the member variables. Then, nobody would recognize the counting words and it would be totally logical.

    private String onesie = "";
    ...
    private String elevensie = "";

    See, pretty elegant, right?

  • Unbelievable 2008-01-07 17:04
    Please kill me now.
  • Andrey Vul 2008-01-07 17:24
    package dailywtf.fixed;
    public class ListBean {
    private String list[];
    public ListBean() { }
    public ListBean(String ... list) {
    if (list == null)
    this("");
    for (int i = 0; i < list.length; i++)
    this.list[i] = list[i];
    }
    public String getElement(int n) throws ArrayIndexOutOfBoundsException {
    if (n < 0 || n >= list.length)
    throw new ArrayIndexOutOfBoundsException(n);
    return list[n];
    }
    public void setElement(String s, int n) throws ArrayIndexOutOfBoundsException {
    if (n < 0 || n >= list.length)
    throw new ArrayIndexOutOfBoundsException(n);
    list[n] = s;
    }
    }
    Furthermore, OP's coding style of
    foo
    {
    bar;
    }
    was an eyesore for me so my replacement has sane indentation and style.
    Also, why had the OP not used arrays? Strings are objects you dumb-ass! Clearly an array is better.
    Also I added range exception checking.
    Had he been my student and I was a teacher, I would've expelled {him | her} from the course.
  • sf 2008-01-07 17:45
    Licky Lindsay:
    Shenanigans. There is no way this code is real.



    I believe it, although I suspect that it was their lack of JSP skills that drove this design rather than them not knowing how to use collections. Otherwise I'd declare shenanigans as well.
  • horrified 2008-01-07 18:21
    com.initrodeglobal... I'll make sure to steer clear of that company.
  • Bobman 2008-01-07 20:01
    HOW do these people ever get a job as a software engineer?
  • tray 2008-01-07 20:52
    Fourteen whatevers should be enough for everyone.
    I'm pretty sure that within a few years a new design pattern will emerge out of this idea, saying that if you have more that 14 fields or methods in your class, you should refactor.
  • Code Guy 2008-01-07 21:25
    Or they could have used the slightly less known

    ArrayList<String> a = new ArrayList<String>(Arrays.asList(new String[] {one, two, three, ...}));
  • darwin 2008-01-07 22:10
    I just read all the comments, and I'm surprised that everyone missed something that seemed obvious to me.

    The purpose had nothing to do with memory or avoiding using objects. That was clearly just a throw away line to try to justify the monster they had created. The telling comment was the one about using this with JSP. They're probably using Struts but don't know how to access a list. So they (wrongly) think they need to get all their data in an object that has {get|set}Foo method pairs (the JavaBean naming convention) so as to be able to reference it as simply "foo" in the JSP. That's why simply using ArrayList wasn't acceptable to them.

    I was going to add that the ArrayList ctor was broken because it confused 1-based and 0-based indexing, but I didn't notice that although they have the cases labeled 1, 2, 3, ..., 14 they have hardcoded calls to .get(0), .get(1), .get(2), ..., .get(13) in those cases.

    Ugh.
  • Pathway 2008-01-07 23:13
    Bosshog:
    This code is so elegant, it makes me want to poke out my own eyes with a fourteen pronged fork.


    That fourteen pronged fork is inefficient. Here, try this shovel!
  • minini 2008-01-08 05:09
    Enterprise Architect:
    I find this class very useful, but it has too many functions, which makes it slow. My improved version (in C++, also for speed):

    #include <string>

    template <int i>
    class EnterpriseListBean : public EnterpriseListBean<i-1> {

    Unfortunately that is only guaranteed to work for values of i up to 17 portably (according to ISO14882::2003(e) the minimal supported maximum of an implementation for template recursion is 17)
  • Jesper 2008-01-08 05:13
    Aargh! Like many of these CodeSOD entries, this makes me want to yank the keyboard from the programmer's hands, type in "delete ListBean.java" and tell him to start over.
  • dkf 2008-01-08 05:22
    Jesper:
    Aargh! Like many of these CodeSOD entries, this makes me want to yank the keyboard from the programmer's hands, type in "delete ListBean.java" and tell him to start over.
    If it was a good old sturdy IBM keyboard, you could use it to beat the programmer to death instead. Which would be doing the world a better favour.
  • Rhialto 2008-01-08 07:24
    Code Guy:
    Or they could have used the slightly less known

    ArrayList<String> a = new ArrayList<String>(Arrays.asList(new String[] {one, two, three, ...}));

    I've seen several references to ArrayList being "better" than Vector.

    Why would you call an array a List? That is TF!

    If you want efficient direct access a.k.a. subscription (but don't care much about efficiency of adding/removing elements) one uses a vector (a.k.a. array). In the opposite case one uses a list.
  • jeti 2008-01-08 07:47
    And when you need to set the value at an index provided at runtime, you can use reflection to find the right setter method. Brillant!
  • Chris 2008-01-08 08:44
    Rhialto:
    Code Guy:
    Or they could have used the slightly less known

    ArrayList<String> a = new ArrayList<String>(Arrays.asList(new String[] {one, two, three, ...}));

    I've seen several references to ArrayList being "better" than Vector.

    Why would you call an array a List? That is TF!

    If you want efficient direct access a.k.a. subscription (but don't care much about efficiency of adding/removing elements) one uses a vector (a.k.a. array). In the opposite case one uses a list.


    Just in case you're being serious, the main difference between Vector and ArrayList since Java 1.2 (so a real long time ago) is that Vector is synchronized. So any instance where only one thread will access your array, ArrayList would be quicker. If you need multithreaded access then you may want to use Vector so you don't need to do your own synchronization.

    Of course there's this snippit in the API for creating a synchronized ArrayList:
    List list = Collections.synchronizedList(new ArrayList(...));
    No idea how that compares to Vector.
  • Gazzonyx 2008-01-08 10:47
    Not only mixed with an OO paradigm, but without leveraging a single piece of inheritence! (subtext: I see your corporate 31337 speak, and raise you one!) ;)
  • Rhialto 2008-01-08 11:47
    Chris:

    Just in case you're being serious,

    I am serious about the naming. It is quite stupid. A SomethingList says that something is a List. Which, according to basic data type properties, is something completely different than an array/vector.

    I'm not that big a fan of C++'s STL, but their basic collection data types, and the associated complexity guarantees, is something they got right.
  • Andrew 2008-01-08 15:12
    Bosshog:
    This code is so elegant, it makes me want to poke out my own eyes with a fourteen pronged fork.


    Why not a spoon cousin?
  • Andrew 2008-01-08 15:17
    The Exorcisim of ListBean:

    I am 1, 2, 3, 4, 5, 6, 7, 8, entry, 10, 11, 12 ,13, 14
  • ishnid 2008-01-08 15:33
    Can't wait until the next CodeSOD, where we'll be shown how they went about iterating over the thing!
  • VGR 2008-01-08 16:23
    Rhialto:

    I am serious about the naming. It is quite stupid. A SomethingList says that something is a List. Which, according to basic data type properties, is something completely different than an array/vector.

    I'm not that big a fan of C++'s STL, but their basic collection data types, and the associated complexity guarantees, is something they got right.

    An ArrayList is an implementation of List which is backed by an array.

    What would you call it?
  • Andrey Vul 2008-01-08 21:28
    VGR:
    Rhialto:

    I am serious about the naming. It is quite stupid. A SomethingList says that something is a List. Which, according to basic data type properties, is something completely different than an array/vector.

    I'm not that big a fan of C++'s STL, but their basic collection data types, and the associated complexity guarantees, is something they got right.

    An ArrayList is an implementation of List which is backed by an array.

    What would you call it?

    I would call it Java API redundancy.
  • Cloak 2008-01-09 04:37
    bd:
    Pay special attention to the constructor that takes ArrayList. If you squint a bit, it looks like a Duff's device. Or in this case, Dufus' device.


    Duff's device or Duff Beer?
  • Lucas Gabriel Sanchez 2008-01-09 07:42
    I'm not the best programmer of the world, but I think that maybe, that code can be improved using an array.. xD.. WTF!!?? WHO IN THE NAME OF GOD WRITE THIS!!!!.. ¬¬
    My grandma can write a better class than ListBeans..
  • Chris 2008-01-09 08:32
    Rhialto:
    Chris:

    Just in case you're being serious,

    I am serious about the naming. It is quite stupid. A SomethingList says that something is a List. Which, according to basic data type properties, is something completely different than an array/vector.

    I'm not that big a fan of C++'s STL, but their basic collection data types, and the associated complexity guarantees, is something they got right.


    It's an ArrayList because it's an implementation of the List interface that's backed by an array. On insertion, the array is resized (normally by a power of two) if the capacity has been reached. In comparison, LinkedList is an implementation of the List interface that's ... surprise, surprise, backed by a linked list. The choice of which implementation to use usually boils down to whether you're more concerned with random access or insertion into anywhere other than the end of the list.

    As for C++ STL, that's just a WTF. It's predicated on copying, and ends up being a memory hog.
  • Chris 2008-01-09 08:36
    Andrey Vul:
    VGR:
    Rhialto:

    I am serious about the naming. It is quite stupid. A SomethingList says that something is a List. Which, according to basic data type properties, is something completely different than an array/vector.

    I'm not that big a fan of C++'s STL, but their basic collection data types, and the associated complexity guarantees, is something they got right.

    An ArrayList is an implementation of List which is backed by an array.

    What would you call it?

    I would call it Java API redundancy.


    Nope, as I point out above, there are different implementations of the List interface because they exhibit different behaviour. Meanwhile in C++ land, and in keeping with Stroustrup's own obsessions, the STL designers were more concerned with interface elegance than performance. The end result is that I find I have to use my own hand crafted containers for C++ quite often because the STL ones are too generalised to perform adequately.
  • jonl 2008-01-09 09:03
    I laughed so hard I made a mess in my pants. Nurse get the medication...
  • pepperbob 2008-01-10 02:00
    Nice! This "solution" is really something that I'd expect from our internal ERP Support Team. I stopped getting upset on this...
  • Rhialto 2008-01-10 06:58
    VGR:
    An ArrayList is an implementation of List which is backed by an array.

    What would you call it?

    If it is an array, I would call it an Array. Not a SomethingList, which is a List. (And if it isn't, you can't trust its name,which disqualifies it too.)

    A List which really is an Array, or the other way around, is the worst of both worlds, since you cannot count on the good properties of either.

    I suppose this miserable situation stems from the fact that there is this base-Interface called List and they felt it necessary to keep the name in subclasses. They could have done something more correct in that area.
  • real_aardvark 2008-01-10 10:25
    Chris:
    Meanwhile in C++ land, and in keeping with Stroustrup's own obsessions, the STL designers were more concerned with interface elegance than performance. The end result is that I find I have to use my own hand crafted containers for C++ quite often because the STL ones are too generalised to perform adequately.

    That's a dubious comment on both Stroustrup and on the STL designers. Much as I love both C++ and the STL, I wouldn't suggest that either one is obsessed with "interface elegance." (basic_string, anybody?) On the other hand, C++ is, if anything, too obsessed with performance.

    If you need high-performance from your containers, may I suggest storing pointers instead? Even with my trusty Knuth Vol II at my side, I doubt I can roll a significantly better container than Stepanov et al.

    I suspect that all the copying is more a result of the functional programming background of the STL lot, but I could be wrong.
  • MdK 2008-01-12 20:10
    And you can eat a Brillant Paula Bean with it afterwards.
  • Ankeet 2008-01-16 13:17
    package com.initrodeglobal.util.presentation;


    Keyword being presentation.

    Wouldn't a -normal- programmer get lazy writing that whole mess and just use one of the millions of more efficient ways to do it? I know I would.
  • Gigitrix 2008-01-23 16:11
    There's an array of witticisms tat I could make here....
  • Andy_randomsuffix 2008-02-01 19:02
    Surely if you mix the OO paradigm with the FC paradigm your code is totally FOOC-ed ?
  • Andy_randomsuffix 2008-02-18 07:10
    Andy_randomsuffix:
    Surely if you mix the OO paradigm with the FC paradigm your code is totally FOOC-ed ?


    DANG! I just re-read the whole thread and saw Grovesy beat me to it in post 169419. (Hangs head in shame).
  • NoAstronomer 2008-10-09 15:13
    (Thread rez alert)

    Which is why I refuse to let the desktop support guys take mine away.