1 Posts Tagged 'LOLcats'
A calm and rational discussion of Java
In the past I believe I may have said that Java was god-awful. I was mistaken. Java is far more evil than any god. Java sucks like the black, empty vacuum-void of nothing that existed before time began.
I'm tasked with maintaining and updating some Java code at work. Today I wandered in to work in a chipper mood. The sun was shining, the birds were singing, life was good. Oblivious, I sat at my computer and fired up Eclipse. 20 minutes later it opened and I was looking at some Java code.
Events played themselves out like they usually do As Java flowed across my computer screen, at first it was a slight twinge in the back of my mind that something was wrong. All too quickly that twinge became a dull sort of deep-seated pain. As the minutes passed, my good mood drained from me like my life-blood draining from an open wound. Joy was replaced with horror at the programming atrocities being committed before my eyes. I'm not exaggerating to say that a few times I've looked at my screen wide-eyed, mouth agape, as involuntary mad laughter escaped me.
Whatever my many other faults, I'm pretty fast at reading code and understanding it. Still it took me over an hour today just to locate the place I needed to add five lines of code to get my job done. Generally I'll start at the top of some 20-level-deep hierarchy of classes and interfaces and abstract classes, and work my way down into it until I look back and realize I have no idea where I came from or what I'm even looking for any longer. You see, public abstract class com.someDomain.project.client.model.table.AbstractEditableTableModel, which extends AbstractTableModel and implements EditableTableModel, which itself is a superclass of GenericTableDataModel and MultiTableDataModel, may contain the stub of a method I have a vague notion I may want to look at someday, but the fun thing about Java is that I get to search the whole hierarchy of imaginary insubstantiatable classes top to bottom until I find the overridding method that really implements the logic I need to see. Then I get to re-search the whole tree to find all the methods that method calls, along with the many separate trees of classes of all the objects the first class uses.
The code I'm dealing with is 210 classes and interfaces worth of Java that does little more than fetch some data from a database and display it in a GUI in a couple of grids. Those 210 classes of course extend and implement many bits and pieces of standard classes from the Java's standard library, meaning the number of classes I really have to deal with is far higher. And most of them DON'T DO ANYTHING.
Most of this code is completely without comments of course, and important variables are named things like s and data. And methods have names like good old actionPerformed; so if the program, you know, performs any actions, I guess I'm covered.
But I shouldn't say it's entirely without documentation. Here's one method along with its documentation.
// used to propogate [sic] privilges [sic] down to the lowest node
public void pushPrivileges()
{
int myPrivileges = getPrivileges();
Iterator i = tables.keySet().iterator();
while( i.hasNext() )
{
tableModel tbl = tables.get(i.next());
tbl.addPrivileges(myPrivileges);
tbl.pushPrivileges();
}
}
This is one of the hundreds of boilerplate methods in the code I'm dealing with. I often wonder what proportion of code in Java actually directly works to solve your problem, and what proportion just flips buttons and turns knobs on hundreds of objects which in turn flip buttons and turn knobs on other objects, most of which have no need to exist, while Java spins its wheels in the mud. The above method would be one or two lines of straightforward Lisp or Ruby code, if this method even had a need to exist. Java is much like a 100-armed monster, who will put 3 of those arms to work to solve your problem if you very carefully tell it how to use the other 97 arms to masturbate itself.
The highpoint of my day though was finding a method called "isHasDeletePrivilege". Only Java could inspire such madness in a programmer. I very barely managed to keep myself from right-clicking in Eclipse, selecting refactor => rename and typing canHasDeletePrivilege. If you try to read Java code from the perspective of a group of retarded pseudo-sapient cats living on the internet, it actually makes a bit more sense.
The worst thing about Java is that it actually just barely can be used to solve most problems, which only continues to encourage people to use it.
