Commons-io: By retards, for retards

A week or two ago yet another Jakarta commons project was inflicted on a largely unsuspecting world. This release didn’t so much as arrive with a bang or make an entrance, it sort of guiltily snuck in hoping no one would notice.

If you were to have a look at the contents of this latest abomination, you’d realise why it’s guilty and ashamed from the outset. Let’s take a brief walk through this remarkable insight into the mind of a a happy idiot java beginner. Yes folks, most of you too were this stupid and ignorant once, so let’s not judge these genuises too harshly.

First up, we have the standard open source pointless class syndrome. This seems to be a vital requirement for any open source project; a bunch of classes that explicitly do sweet fuck all. In commons-io, these take the form of True/FalseFileFilter. Wonderful file filters that always pass and always fail, just what your project needs.

Stepping back a little, one has to wonder at whether the world really, really needs a file filter package whose sole purpose is to bring together the built-in FileFilter and FilenameFilter. These works of wonder take up 13 classes of the 34 in the whole jar. The whole premise is somewhat ridiculous, anyone who cares a whit about performance, encapsulation, or readability would NOT build up file filters by contorting their code into bizarre shapes just so they can do something like new OrFileFiler(new NameFileFilter(), new AndFileFilter(new TrueFileFilter(), new NotFileFilter(new FalseFileFilter(), new SuffixFileFilter())));. At the risk of being controversial, might I suggest doing what any sane person would, and just writing your own goddam filter that does exactly what you need it to?

If only the horror ended there. When these clever kids were taught Java, nobody bothered explained the standard API to them, or how it contains an awful lot of handy-dandy classes that one need no re-implement. Witness the genius of BufferedOutputStream! commons-io of course ignores that, and includes the inspired DeferredOutputStream. What does it do? Why, it buffers, but only once! Latter chunks are no longer buffered! Still, they should be forgiven, as this functionality is something that all of us regularly make use of, I mean, who DOESN’T need a stream that has one buffer chunk then starts streaming?

Unconvinced yet? Well, here’s the crowning glory of this package of congenital defects. IOUtils.toByteArray(String). The more perceptive and java-savvy amongst you might remember that String already has a getBytes method. Oh well, I guess that’s what they call in the implementation. Not so! They instead creating a byte array output stream, write the string into it, then return the contents of the stream as byte[]. Why oh why weren’t these people taught that strings are immutable? Why did nobody think to point out to them that if you modify the byte[] of a string.getBytes(), the string itself is unaffected? Of course, let’s not shame these Jakarta folk any further by being pedantic and mentioning that converting a String to byte[] is pretty silly if you’re not going to take encodings into consideration (needless to say, they’re blissfully encoding ignorant all over the API).

It’s easy to laugh at these wankers and dismiss them out of hands. That’d be irresponsible though. As adults and contributors to Java it is our job, nay, our duty! to educate and help these poor souls. So do the world a favour. Find the nearest Jakarta committer, and beat him like a red-haired bastard child he most likely is, while explaining to him the java fundamentals. Maybe this time round they’ll stick.

Oh and for those of you desperate for more JBoss goodies:

From: "Nathalie Mason" 

Received: from galaga ([65.81.161.44]) by imf15bis.bellsouth.net

JOnAs motherfuckers. At least when the JBoss/BEA killer thread got posted on
the ServerSide we didn't have to stoop so low as to post it ourselves.

"We think JOnAS...is...maybe..er.a better app server than JBoss."

If they are going to use negative PR tactics, they are going to have to  come
up with stronger language than that

What one of you guys needs to do is make up an alias on Serverside and  post
something like
"JOnaS rules, JBoss sucks big donkey dicks"

That way they'll get the choirboys after them too

22 Responses to “Commons-io: By retards, for retards”

  1. Henri Yandell Says:

    A most detailed investigation.

    The Filter issue is your own personal coding choice, bespoke vs lego. I’m with the lego.

    DeferredOutputStream will be asked to justify its existence, as will the IOUtils.toByteArray method.

    Finally, I’ll have you know that per dictum #1267, by order of the chair, red-haired Jakarta committers have dyed their hair blonde.

  2. Henri Yandell Says:

    http://jakarta.apache.org/commons/io/

    shame on you Hani :)

  3. Anonymous Bastard Says:

    The IOUtils class, which has only static members states this in its constructor:
    “Instances should NOT be constructed in standard programming.”
    Do I need to point out that the constructor is public?

  4. chester Says:

    The reason for the public constructors is because scripting tools like Velocity have problems calling static methods. They have to invoke methods on an instance, even if the methods are static.

    I’m not even sure if this is still true (about Velocity) but I think that this is the reason.

  5. Multiple choice Says:

    Avoiding copypaste, what would you choose?:

    1. programing macros in a static class? (***Util)
    2. programing a new Class with one method? (for thread safety)
    3. programing/using a codegenerator that does the copypaste at build-time?
    4. programing a good structured design?
    5. programing a good oo design?
    6. use a commons-**** package?

  6. a retard Says:

    now

    thats

    what a bile should look like :)

  7. fletch Says:

    While you’re being pedantic, it’s “dismiss them out of hand”, not “dismiss them out of hands”… unless, of course, you were doing a bad wanker joke… but anyone who needs both hands to wank is either doing it wrong or really shouldn’t be wanking.

  8. Jed Wesley-Smith Says:

    if they wanted to be useful, a toCharArray() that deals with char encoding properly would have been great (unicode can be a minefield to the unwary).

    I have to profess though, the rest of IOUtil is pretty handy, its very easy to fuck up those pesky Reader->Writer kind of operations in weird and wonderful ways…

  9. Jed Wesley-Smith Says:

    duh, they did! scuse my ignorance, but the copy(*) methods take encodings as args or use the default if unspecified. oh well, back to my hole…

  10. Jed Wesley-Smith Says:

    one last thing [haven't learnt yet, probably should post with a pseudonym] re. immutable Strings … on oldie but a goldie:

        public String getAString() {
            //get a reference to the private field value in String class.
            java.lang.reflect.Field stringValue = String.class.getDeclaredField("value");
            //make it accessible
            stringValue.setAccessible(true);
            //unsuspecting string
            String sittingDuck = "sittingDuck!!!!!";
            //black magic happening here
            stringValue.set(sittingDuck, "hastaLaVistaBaby".toCharArray());
            //guess the output of this!
            return "sittingDuck!!!!!";
        }

    apparently this has been fixed in some recent JDK, but not sure which… doesn’t affect getBytes() but, which I have just noticed ALSO has char encoding support … dang I’m slow today!!! [note to self, NEVER post under real name the day after a big rehearsal]

  11. wazlaf Says:

    hani-

    if I remember properly, you wished for the existence of such a device in a previous bile. this might be something for you:

    Printer which takes in toilet paper

  12. Clown Puncher Says:

    >but anyone who needs both hands to wank is either >doing it wrong or really shouldn’t be wanking.
    >
    >Posted by fletch at 27.05.2004 19:39:46

    OR has a really BIG FAT CLOWN!

  13. Some reader Says:

    What’s encapsulation and information hidding?

    “Though the code may use Java objects, it does so in a manner reminiscent of a by-gone era: utility functions operating on data structures. Welcome to 1972!”

  14. Jakarta Tard Boy Says:

    What is does “immutable” mean?

    Sorry for my poor Engrish. I am from Pakistan where we murder each other over 100 rupees.

  15. Jakarta Guy Says:

    Shame on you! Not everyone in the world is as healthy and fat as pigs like Americans.

    Sorry for my bad English. I’m from Indonesia, where all candidates running for presidency can all go to hell … especially Amien Rais (fuck you!), except Susilo Bambang Yudhoyono (yay! Good Old Nationalist Military Figure — kick away those retarded religious candidates)

    > What is does “immutable” mean?
    > Sorry for my poor Engrish. I am from Pakistan > where we murder each other over 100 rupees.

  16. Jakarta Guy Says:

    Oopss… I mean Wealthy. That proved my bad English.

  17. Jakarta Tard Boy Says:

    I said I am from Pakistan. I am thin as toothpick.

    I still want know now what mean “Immutable”?

    Sorry for by mad English. I am from the pit of the arm Rawalpindi. We have no immutables.

  18. HolyOne Says:

    From the out sight, Apache looks good. and true,some of them may be good.

    But with so many utils crap around, it really sucks now a days.

    Yeah, how about somebody releasing an util library to wrap up all the fu**ing utils around??

    Why the hell on earth, these people should leave the programmers to do the job? If somebody cannot do even a code to use string properly, why the hell on earth, they should be paid as programmers?

    Sucks is the milder word!

  19. Rampant Clown Says:

    While Henri likes his Lego, I think he’s playing with it on his own. Does anyone actually use these Jakarta bollocks in their products ? I mean, do you insist that your users will have to download this filth or do you just write what you need since it takes so little time to do it?

  20. Janek Bogucki Says:

    There are some real gems available from the Jakarta project. My personal time saving favourites are the simple and effective org.apache.commons.lang.builder.HashCodeBuilder and org.apache.commons.lang.builder.EqualsBuilder.

    I wouldn’t be without them.

  21. INNOVATION INNOVATION INNOVATION Says:

    http://trijug.org/downloads/JBOSS1.ppt

    crazy & funny & pathetic

  22. Anonymous Says:

    My personal time saving favourites are the simple and effective org.apache.commons.lang.builder.HashCodeBuilder and org.apache.commons.lang.builder.EqualsBuilder.

    Yeah, right, time saving. Till the day you realize that the company app server has restricted relflection capabilities and you end up writing the same old bull hashCode methods anew.

Leave a Reply

You must be logged in to post a comment.