Java Out of the Enterprise

I don't really think of sys-con.com's linux site when I'm looking for Java news but this entry caught my eye. In it, he complains about the tendency of java libraries to make heavy use of patterns like the Factory pattern to provide as much flexibility as possible. He's not the first one I've heard complain about this tendency.

So what's the reason for this alleged over-engineering. The author goes on to praise his eventual perl solution for the speed with which he was able to solve his problem. Certainly one consideration for library selection is speed of development and ease of use. So why, as java developers, do we build in so much (often) unnecessary complexity? My personal theory is that from the start as (professional) java developers, we're taught to think in terms of the enterprise. That means considering the myriad different platforms the application will run on: databases, operating systems, etc. And that's certainly a valid concern but things like JDBC operate without all the Factory this and getInstance that.

So why are we so enamored with all this complexity? Is it really worth it? I've gotten used to much of it

ArrayList vs LinkedList

I was really surprised to see this article. I typically have only ever used ArrayList because it fits my needs but I've always reserved the option of inserting another List should the situation change. After reading this, though, it doesn't seem there's much point to using LinkedList ever. I can see why operations in the middle would take a while since you have to scan the list to find element n but I didn't expect it to overshadow the cost of adjusting the array. (Though array copies are reasonably fast for most purposes). What really surprised me was the work on the end. That should be almost instantaneous provide it's a doubly-linked list.

What these numbers point out for me is that perhaps the Collections code should be revisited and vigorously optimized. I've heard too many stories of people writing custom implementations that are faster than the JDK offerings. Granted, the JDK is solving a generic problem and custom lists can be optimized for special cases, but none of the anecdotes I've heard really deal with corner cases. The Collections classes are too heavily used to be as inefficient as they appear to be.