Don’t Be That Developer

Back in April of 2005, I came across a strange syntax in some java programming I was doing for work.

Class.forName("[S");

Back then, there was no convenient free StackOverflow site to quickly find an expert who would know off the top of their head what that syntax meant. And searching for “[” on Google certainly wasn’t a winning solution since square braces weren’t even indexed characters. How do you search for something that you don’t know the name of?

It took a while to find the answer. It turns out, it was a tricky way, using reflection of saying the same thing as short[].class

Really? Who would have guessed? It certainly wasn’t clearly documented anywhere, especially not in the code where it was used. And where it was used, there was absolutely no reason it needed to be using reflection and using some sneaky syntax.

Had the developer just kept it simple and written so much as a comment, or used a more straightforward, well-documented syntax the code would have been easier to maintain. We’re not playing Code Golf here (though even if we were, the non-reflection version still comes out shorter)!

Java’s GregorianCalendar

Who would have thought up a calendar where the month starts at 0-11 but the days of the month run 1-31 (or so)? Its nice having full featured calendar utilities…but they could be slightly more intuitive to use, or at least consistent.

Doh! of the day–stupid but legal…

Interaction interaction = null;
new Interaction(
i, j, k, l, m, n, o
);
return interaction;

note to self: don’t do that

Amusing bug of the day…

In oberon, java, and sparc assembly:

CONST_TRUE: .asciz "FALSE"
CONST_FALSE: .asciz "TRUE"

Play spot the error…

the difference between 35 errors and zero errors. Stupid copy-paste typos…

pointloc[0]=(float)i./(float)(NUMPTS-1.);
pointloc[1]=(float)j./(float)(NUMPTS-1.);
pointloc[2]=(float)k./(float)(NUMPTS-1.);

pointloc[0]=(float)i/(float)(NUMPTS-1.);
pointloc[1]=(float)j/(float)(NUMPTS-1.);
pointloc[2]=(float)k/(float)(NUMPTS-1.);