August 28, 2003
Probably the stupidest code I've seen to date..

It went something like this.. (variable names changed to protect the innocent)


public List getWhatever(int id) throws NotFoundException
{

    ArrayList thisList = new ArrayList();

    try
    {
       thisList = (ArrayList) getItFromSomePlaceElse(id);
    }
    catch(Exception)
    {
        // ignore
    }

    return (List) thisList;
}

Just like that.. stupid casts and all.. *banging head on wall*

Posted August 28, 2003 08:35 PM in Funnies
TrackBack URL for this entry: http://www.unix-girl.com/mt/mt-tb.cgi/895
Comments
On August 29, 2003 03:06 AM Koen added:

i hope this was meant to be stupid code. :)

#
On August 29, 2003 04:38 AM Yashima added:

I can beat that one ... ;-)

while(true){
....
if(something){
....
break;
}
else {
....
break;
}
}

http://www.newgods.org/~yashima/dd/whiletrue.html

And it was not the only 'weirdness' I encountered in that project

#
On August 29, 2003 05:54 AM Patrick Schriner added:

Cast are very nice if someone does a rename refactoring, say with Eclipse.

You donīt think Eclipse could recognize something like:

something.instanceOf Class .forName("SomeClassName.class");

and change "SomeClassName" to the refactored name...

#
On August 29, 2003 08:08 AM kasia added:

No, these casts are stupid.. It's casting an interface to the inheriting object, then casting the inheriting object back to the interface to return it.. for absolutely no reason.

Can you say broken code if anyone ever changes the implementation of the called code to say.. LinkedList?

#
On August 29, 2003 12:28 PM Arcterex added:

Perl allows you to write far more bizzare things. The code below does a lookup to see if the answer provided is the correct answer. I think. Maybe, it's been a day or so since I wrote the code so I'm a bit fuzzy :)

$d[0]->[$q->{number}-1]->{answers}->$answerlookup{$mydata{$q->{number}}}]->{answer}

#
Trackbacks