Sunday, May 29, 2005

Approaching desktop usability

I read this tongue-in-cheek article over at News Forge. Nicely written from the perspective of a (Gnu/)Linux user evaluating Windows XP. The title say it all; Windows rapidly approaching desktop usability. Miller makes an issue out of a problem with an LCD monitor during installation. More seriously, he complains "Windows XP networking: Not for amateurs". I know his pain; I have struggled long with my wife's laptop (running XP Home) to get it to connect to our wireless network. Each time I declare victory, each time my wife reports back after a few days that she doesn't have Internet. connection. Most recently, I found that a mis-typed ssid was being remembered, when the correctly typed ssid was not. Only brute force deletion (editing the registry) fixed that one. Curiously, my laptop which has inbuilt 802.11g has little trouble connecting; and that despite there being no Linux driver; I use the windows driver together with ndiswrapper.
And the old trusty old W2K Server box that we connect to; that runs fine -- as long as I don't use the the console (and definately not Windows Explorer, which freezes at the drop of a hat). But all is not rosy in Linux either. Recently, the sound system started to report CPU overload. The DVD player Xine used to work fine, but now consumes 100% CPU. MPlayer has no such problem, but it suddenly refused to start because the there was no sound system. Printing -- a major headache on Windows XP -- works just fine using CUPS, apart from one irritating little detail; every time our wireless printer cycles power, When it changes IP address, I have to feed it manually into the CUPS setup. But at least that is a deterministic process compared to coaxing the XP laptop to connect to our printer server. That is pure black magic.
Swapping between W2K (at work) and Linux lets me see the good sides (and the not so good sides) of both. On Linux there is the Gimp; an amazing tool that I use to process RAW images from my digital camera. On Windows there is the awesome Rational Rose. Amazing functionality, disasterously poor UI. An increasing number of aplications are available on both platforms; Eclipse (though the Linux version has some small cosmetic defects); Firefox/Thunderbird; even the Gimp (though it doesn't work for me as there are DLL conflicts).
To be honest, I cannot say that either is approaching "desktop usability". I spend far too much time futzing with non-productive things. Where is the Desktop OS that "just works"?

Category: Desktop

Monday, May 16, 2005

Debugging Javascript

Debugging Javascript has its own set of challenges; often aggrevated by a lengthy build/deploy cycle time. With the increased usage of asynchronous server calls (now with the fancy buzz word, Ajax), life has become a few notches more difficult. We still have the tried and tested alert pop-ups, And there are Javascript debuggers where one can step through the code line by line.
Alas, with a cascade of asynchrous actions, you are quickly lost. Timing and sequence matters, and your debugging tools freeze the action and most likely disturb the very events you are trying to understand. In situations like this, it is helpful to write to a log that you can inspect when things have calmed down. Some time back, I recall seeing a little utility that allowed you to write to a scrolling window on the page. I no longer have a refernce to that article, so I spent last Saturday creating my own little utility.
The concept is simple; a simple function ( called debug() ) writes to the window. If the window doesn't exist, it gets created on-the-fly. Each call to debug adds a new paragraph to the window -- I used an iframe to save me some hassle with selects shining through on IE.

var box = document.createElement ('iframe');

That gets appended to the body element. Inside (this.iframe.contentWindow;) I create a container <div>. I add the text, wrapped in a paragraph element.

var p = this.doc.createElement ('p');
p.appendChild (this.doc.createTextNode (text));
this.container.insertBefore (p, top);

All formatting is done by setting styles directly on the javascript objects; no need for an external stylesheet. To add a little finesse, I resize the window (up to a certain maximum height. After that, the iframe body takes car of the scrolling for me. I highlight the most recent paragraph and all debug text are prefixed with time [hh:mm:ss]. As the final touch, I set the opacity to 0,75 so the underlying shines through. That's it. Life just became a little simpler.
Category: Programming,Javascript

Thursday, May 05, 2005

Unit Tests

I'm a "test early, test often" sort of person, so unit tests seem natural to me. This leaves me constantly amazed when I find people who write unit tests to fulfill the letter, but not the spirit. I'm referring to unit tests that fail to test anything significant; or anything at all.
Yes, I have seen (more than one) example of (supposed) unit tests that cannot fail – no assertion – or in the extreme no test code at all. The latter, admittedly was an automatically generated test skelton, but it was commited to the source code repository and remained unchanged for months; it may even still be there, for all I know.

Monday, May 02, 2005

Validation

There's an interesting article over at Juicy Studio on client-side form validation. It's the old Javascript validation stuff we've been doing for ages; with a new twist. I note there is still a lot of confusion; client-side validation is mostly a fast check for well-formedness, not actual validity. To check the latter usually requires a trip to the database.
Another point is that we can (and should) show validation failure as soon as possible; not wait until the user tries to submit the form. I've tested this with users and they seem to like it. I might just write a longer article on this subject.
Category: Programming,Javascript