Comment On These Go To Fourteen

"Actually," the lead on Chris G's team said defensively, "this is a quite elegant solution for displaying data in a JSP. This way, we don't have to use the real object and can save memory." [expand full text]
« PrevPage 1 | Page 2 | Page 3Next »

Re: These Go To Fourteen

2008-01-07 08:02 • by Cheatah (unregistered)
Company policy:

- never use collections
- never use generics

Re: These Go To Fourteen

2008-01-07 08:02 • by snoofle
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.

Re: These Go To Fourteen

2008-01-07 08:06 • by sir_flexalot
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***.

Re: These Go To Fourteen

2008-01-07 08:12 • by Blain (unregistered)
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...

Re: These Go To Fourteen

2008-01-07 08:14 • by Licky Lindsay
Shenanigans. There is no way this code is real.

Re: These Go To Fourteen

2008-01-07 08:15 • by Friedrich (unregistered)
"//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

Re: These Go To Fourteen

2008-01-07 08:19 • by Rohan Prabhu (unregistered)
when i see people like this getting hired.. i get assurance of a bright career...

Re: These Go To Fourteen

2008-01-07 08:23 • by Hans (unregistered)
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.


Re: These Go To Fourteen

2008-01-07 08:29 • by MAV (unregistered)
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!

Re: These Go To Fourteen

2008-01-07 08:29 • by Erik (unregistered)
Right... but this one goes to eleven.

</spinal tap>

Re: These Go To Fourteen

2008-01-07 08:32 • by Csaboka (unregistered)
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!

Re: These Go To Fourteen

2008-01-07 08:33 • by Cheatah (unregistered)

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;
}
}

Re: These Go To Fourteen

2008-01-07 08:33 • by Case (unregistered)
The next-worst part is that they actually typed in all those getters and setters... any half decent editor can do it for you.

Re: These Go To Fourteen

2008-01-07 08:35 • by Carra (unregistered)
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!

Re: These Go To Fourteen

2008-01-07 08:36 • by Tassos (unregistered)
169401 in reply to 169398
Nope. Won't work, constructors aren't inherited.

Re: These Go To Fourteen

2008-01-07 08:39 • by java.util.collection (unregistered)
169402 in reply to 169394
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

Re: These Go To Fourteen

2008-01-07 08:42 • by java.util.collection (unregistered)
169403 in reply to 169401
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

Re: These Go To Fourteen

2008-01-07 08:43 • by java.util.collection (unregistered)
169404 in reply to 169401
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

Re: These Go To Fourteen

2008-01-07 08:45 • by ObiWayneKenobi
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.

Re: These Go To Fourteen

2008-01-07 08:50 • by ThePants999
169407 in reply to 169401
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!

Re: These Go To Fourteen

2008-01-07 08:51 • by Aicho (unregistered)
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

Re: These Go To Fourteen

2008-01-07 08:54 • by John (unregistered)
169409 in reply to 169397
Err, its the new generation of programmers that come up with this crap.

Re: These Go To Fourteen

2008-01-07 08:57 • by dkf (unregistered)
"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...

Re: These Go To Fourteen

2008-01-07 09:03 • by hc (unregistered)
Well, obviously this class should implement Iterable<String>. How silly of them, now their memory efficient list can't be iterated!

Re: These Go To Fourteen

2008-01-07 09:08 • by nobody (unregistered)
It is clear that they intend to upgrade to HEX in the near future.

Re: These Go To Fourteen

2008-01-07 09:12 • by Matt (unregistered)
169413 in reply to 169397
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.

Re: These Go To Fourteen

2008-01-07 09:18 • by Emphyrio (unregistered)
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, ... };


Re: These Go To Fourteen

2008-01-07 09:20 • by Zygo (unregistered)
  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

Re: These Go To Fourteen

2008-01-07 09:20 • by mightybaldking
169416 in reply to 169398
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!

Re: These Go To Fourteen

2008-01-07 09:44 • by Grovesy
169419 in reply to 169397
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”

Re: These Go To Fourteen

2008-01-07 09:50 • by Bosshog (unregistered)
This code is so elegant, it makes me want to poke out my own eyes with a fourteen pronged fork.

Re: These Go To Fourteen

2008-01-07 09:53 • by pitchingchris
169422 in reply to 169396
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.

Re: These Go To Fourteen

2008-01-07 09:54 • by hc (unregistered)
169423 in reply to 169414
Or
Arrays.asList(one, two, three)

Re: These Go To Fourteen

2008-01-07 10:02 • by Or CASE-FOO (unregistered)
169424 in reply to 169397
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.

Re: These Go To Fourteen

2008-01-07 10:31 • by Quiark (unregistered)
I always wondered how to store multiple values in a class. Thanks for this tip !



:D

Re: These Go To Fourteen

2008-01-07 10:39 • by Some 25th Grader (unregistered)
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.

Re: These Go To Fourteen

2008-01-07 10:56 • by Spectre
169450 in reply to 169397
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...

Re: These Go To Fourteen

2008-01-07 10:57 • by Sam (unregistered)
169451 in reply to 169421
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?

Re: These Go To Fourteen

2008-01-07 11:01 • by bd (unregistered)
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.

Re: These Go To Fourteen

2008-01-07 11:10 • by dkf (unregistered)
169456 in reply to 169453
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.

Re: These Go To Fourteen

2008-01-07 11:21 • by OperatorBastardusInfernalis
I wouldn't touch this with a fourteen foot pole...

I'd need the fifteen foot pole to touch this.

Re: These Go To Fourteen

2008-01-07 11:48 • by TM (unregistered)
I just died a little inside...

Re: These Go To Fourteen

2008-01-07 12:36 • by Andrew (unregistered)
169488 in reply to 169394
A dynamically-sized array is a Vector.

Re: These Go To Fourteen

2008-01-07 12:39 • by Zylon
169491 in reply to 169422
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.

Re: These Go To Fourteen

2008-01-07 12:50 • by The Outlaw Programmer (unregistered)
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...

Re: These Go To Fourteen

2008-01-07 12:51 • by yoz-y (unregistered)
The real WTF is that they didn't use the automated Getters and Setters generation

Re: These Go To Fourteen

2008-01-07 12:54 • by Enterprise Architect (unregistered)
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;

Re: These Go To Fourteen

2008-01-07 12:58 • by tray
This is the FOURTEEN-CASE paradigm, not the FOR-CASE one.
You should know that.

Re: These Go To Fourteen

2008-01-07 12:59 • by SenorLapiz
169498 in reply to 169397
It's the FOURTEEN-CASE paradigm!

Re: These Go To Fourteen

2008-01-07 13:25 • by Leak (unregistered)
169512 in reply to 169464
OperatorBastardusInfernalis:
I'd need the fifteen foot pole to touch this.

HAMMER TIME!
« PrevPage 1 | Page 2 | Page 3Next »

Add Comment