Wednesday, February 07, 2007

Garrulous Software

A particularly annoying characteristic of software these days is excessive chattiness. This occurs at both the user and developer level. In fact, one of the things I prefer on the Mac vs. Windows is the lack of meaningless messages the Mac generates (No, I do NOT want to clean off my desktop right now!). Pestering messages at the OS level distract from your attention and diminish your productivity. In The Humane Interface, Jef Raskin discusses the locus of attention, which is the work you are trying to perform. Anything that moves your locus of attention had better be a) relevant to your work and b) urgent and important. In fact, I think its a good idea to turn off the automatic notifications of email arrival, especially if it interrupts real work. Experts on "flow" maintain that it takes up to 20 minutes to get back to that deep concentration state, and it gets harder as the day goes on to overcome the inertia required to get back to that flow state.

The problem in the development world is much worse. It seems like the norm now to generate tons of meaningless noise. Think about application server startup, scrolling messages into the console faster than you can read it. 99% of that information is just the application server saying, over and over again like an idiot, "I'm OK...I'm OK...I'm OK.............I'm OK" (that last one was an EJB loading). The only thing that allows you to see errors is the massive stack traces that come from errors in the J2EE world. In fact, this problem is so bad that developers have taken to dubious practices to make their own messages to stand out from the flood of useless information. Admit've put a Systen.out.println() in your J2EE code to debug it (a whole other subject). And, to make yours stand out from the noise, you put 30 or 40 "~"'s in front of it. Of course, your coworker is doing the same thing, and they use 30 or 40 "#"'s for theirs. Before long, application servers look like they have Tourette's Syndrome, spewing mostly meaningless noise.

My pair and I encountered this very problem recently. We were working with client code that makes heavy (handed) use of Log4J to spew out messages to the console. Unfortunately, that makes for ugly unit test results: you can't see the interesting stuff for all the immense noise being generated by the code under test. In this case, it wasn't as simple as turning off the logging level (the code under test was creating an instance of something that had its own logging stuff buried deep inside). So, after a little thought, we figured out how to shut it up.

In out test case, we unplug the normal output stream, like so:

protected void setUp() throws Exception {
originalOut = System.out;
System.setOut(new PrintStream(new DumbOutputStream()));
And, in tearDown, we put it back:

protected void tearDown() throws Exception {
Our "DumbOutputStream" isn't stupid, just quiet:

private class DumbOutputStream extends OutputStream {
public void write(int b) throws IOException {
//do nothing, because I'm dumb.
This effectively shut off the fountain of noise, leaving the testing framework's output (which occurs on System.err, not System.out) alone. Sometimes, you have to work hard just to shut something up.

Friday, February 02, 2007

Inside Edition: Star Wars

Warning: this blog post is a complete waste of your time!

On the Relevance site, I saw a link to this fascinating analysis of the connections between the first Star Wars trilogy (episodes IV-VI) and the second one (episodes I-III). As much as I'm loathe to admit it, I've done some thinking along these same lines, especially since 2 things have recently happened: 1) I got a new HDTV and 2) HBO has turned into the "All Star Wars Station" (but only for episodes I and III -- they must not have rights to II). You should probably read the analysis before you go on (or it won't make much sense). I'll wait.

In fact, the only flaw I can find in the analysis is the fact that the Jawas weren't at first going to sell R2D2 to the Skywalkers -- it was only after the other similar droid blew up (maybe R2D2 did something to him in the hold of the Jawas' ship?) But it kills the idea that the reason they ended up at the Skywalkers was some sort of deal with the Jawas (unless they double crossed him). See, I told you this was a waste of time, right?

Actually, I distinctly remember interviews with Lucas back in the late 70's where he talked about a trilogy of trilogies (it was supposed to go episodes IV-VI, I-III, and then VII - IX). He has since retracted that statement (and claims he never made it). Whatever. Given how much work it is, I completely understand.

But I always thought that it would be cool in episode IX for C3P0 and R2D2 to suddenly reveal that they are in fact the keepers of the force, much like some of Asimov's robot stories where the robots turn out to be the guardians of mankind while pretending to serve him. And, if you take C3P0 out of the equation (in light of the analysis above), then R2D2 can be said to be the guardian of the good part of the force. That would be cool!

When I want to waste some more of your time, remind me to tell you about the plot idea I have for the origin of the Borg...