Static Imports are Evil

February 6th, 2004

Michael Santos explores a few features of Java 1.5. As part of it he uses the new static import feature and asks what people think of it. I think it’s the most evil invention in coding I’ve seen since while (++i < 5) type statements.

If you saw the line of code:

long time = nanoTime();

where is the nanoTime() function? In 1.4 and below it is obviously in the current class - in 1.5 it could be anywhere and the only way to find out is to scroll all the way back up to the top of the file and read through every import statement. Then consider something like:

err.println("Hello world.");

Where’s the print statement? Everyone knows about System.err.println so that must be it, unless err was a debug statement declared at the top of the file…

Is it really that difficult to type System.nanoTime() instead of just nanoTime()? Programmers seriously need to learn some more discipline instead of always taking the easy way out and forgetting about the guy who has to read the code after them.

In about 3 years time when I actually get to use Java 1.5’s features (backwards compatibility being as important as it is), the first thing that will be added to my coding guidelines will be no static imports - right next to no ++i or i++ embedded in other statements.

Garageband

February 6th, 2004

Fear stuck deep into my heart, a chill ran down my spine… I reread more carefully what I feared I had seen: “I’m going to be a pop star!” My heart pounding - not another wanna be pop star! Please don’t let it be true! My morbid curiosity aroused, I had to investigate - surely there was a painless explanation….

After a few minutes playing with GarageBand

Arggg! Could this be any worse? What abomination am I about to subject my ears to? Do I dare click that link? I had to, I had to know just how bad it was. Hands shaking in fear of what I might hear, I clicked….

ba ba, da da da doo doo da

My foot tapped, my head grooved. What just happened here? That was actually pretty good…. Is it possible that someone who so brazenly refers to themselves as a pop star could actually come up with a cool lick? What kind of wonder is this so called GarageBand? And how soon can I get a copy?

So Matthew when do we get to hear your first complete works?