Monday, July 19, 2010

Geek Out Time

A bit of a gripe today.

The more I read this one developer's code, the more I'm convinced he is was on drugs. Fortunately, this particular developer isn't working for the company I work for anymore, so I'm in little danger of him introducing more braindead ideas. Any single one of his eccentricities of programming is enough to cause a grown man to break down and cry, while all of them taken at the same time can cause such trauma to the brain that its only line of defense is retrograde amnesia.

Where do I begin? Well, for starters he doesn't like using constants. He has a Java class called "Constants", fills it with static variables, and capitalizes their names, but unfortunately they're not actually constant since he forgot to include the "final" qualifier. This in of itself would not be a problem if he used the variables as constants. But unfortunately, they get assigned and reassigned seemingly at random. Thus, just about every variable in the program is effectively a global variable.

Then there's his complete infatuation with Strings. Why bother storing a number in an int or double, when you can store it in a String? What else could String.valueOf() and Integer.parseInt() be used for?

There's also a complete lack of knowledge of data structures. Everything that can be put into an ArrayList is put into an ArrayList. It's by far his favourite data structure, and it seems to be the only one he knows. A few times he created a new class to encapsulate data, but they all only have one member: An ArrayList. Different pseudo-data members are implemented as indices into the ArrayList.

This is by no means a complete list of his deficiencies as a programmer. A lack of Object-oriented design (or understanding) cripples any readability in the code. No exceptions are handled. Memory leaks in all the UI, because instead of updating a field on a form, the form hides itself and creates a new form with the new value.

But one of the best facepalming issues I have come across is his method of populating a database from a flat file. Most programmers would read a line of data (which contains all the data required for a single database record) and write it out to the database. Since ArrayLists are his favourite data structure, he decided to load the entire flat file into an ArrayList of records. And since he likes to implement classes are ArrayLists, the database is actually stored completely in memory as an ArrayList of ArrayLists. Only after the entire file is read is the ArrayList iterated through and written to the database.

If you'll excuse me now, I'm going to drink myself into oblivion.

1 comment:

  1. I suppose re-writing it yourself is out of the question?;)

    Frustrating!

    ReplyDelete