«

»

Mar 17

Lost in a Maze of Twisty Little Java Classes: How often is “infinite scalability” and extensibility really needed?

But look, you found the notice, didn’t you?

Yes yes I did. It was on display at the bottom of a locked filing cabinet stuck in a disused lavatory with a sign on the door saying Beware of the Leopard. — Mr. Prosser and Arthur Dent, The Hitchhiker’s Guide to the Galaxy

While digging through someone’s code to find proof of an observed behaviour, I was caught up in the maze that is Java inheritance. I really believe that many Java API’s suffer from a serious rejection of YAGNI. When I have to trace through fifty gazillion (yes, it really seemed like there were that many!) classes, interfaces, factories, and abstract classes just to find a particular flavour of a HTTP client (which, by the way, is deprecated) in order to discover that it attempts by default to reuse a connection, I feel as though I’ve entered the depths of Vogon Bureaucracy.

“With simplicity, portability, scalability, and legacy integration, the J2EE platform is the platform for enterprise solutions.” — Sun Microsystems

“With great scalability comes great complexity” — Not Stan Lee

“With great complexity comes great consultant fees” — Yoyodyne Consulting

As it turns out, the calling class of the class in question is not threadsafe. This does not lend itself to scalability.

I think part of the frustration for me here is one of philosophy. I do find it ironic that these complex systems grew out of a company which was an early champion of UNIX. I sense in the rush to be “enterprise”, Java lost sight of the UNIX Philosophy.

… UNIX programs do quite trivial things in isolation, but, combined with other programs, become general and useful tools. — Kernighan and Pike, The UNIX Programming Environment

So instead of something like this:

513uh-JhKzL._SY450_

we get:

ultimate-swiss-army-knife1-640x533

Going back to the original point, all of this is in an effort to provide a “Full implementation of all HTTP methods (GET, POST, PUT, DELETE, HEAD, OPTIONS, and TRACE) in an extensible OO framework.” How often is extensibility really needed for something as fundamental as HTTP? When was the last time a new method was added to the specification? Is a framework really needed for something as fundamental as HTTP? I can understand creating an abstraction layer, but in the course of this archeological quest, I found myself digging through layer after layer in order to reach the core. Inanna only had to pass through seven gates; I investigated over a score of Java classes! Each layer adding its own complexity and overhead. Function calls are not free, nor are layers of abstraction.

Yagni, the Development Assistant

Yagni, the Development Assistant

Il semble que la perfection soit atteinte non quand il n’y a plus rien à ajouter, mais quand il n’y a plus rien à retrancher. — Antoine de Saint Exupéry

A good discussion of complexity and whether or not it is truly needed can be found in Neal Ford’s Emergent Design and Evolutionary Architecture.

Leave a Reply

%d bloggers like this: