Monday, November 28, 2005

80 percent by convention

In an interview published recently by eWeek, David Hansson (creator of Ruby on Rails) made a statement, which wonderfully summarizes my ideas on the way APIs, libraries and frameworks should be designed. It can also be considered an addition to my previous post – I was trying to say the same thing, but was unable to put it into such an elegant phrasing:

“As long as you do what most people want to do most of the time, you get a free ride. No configuration necessary. So get the 80 percent by convention, tailor the last 20 percent by hand.”

I definitely should try Ruby on Rails: it is always a great pleasure to use a tool when you and the tool’s designer share the same ideas.

Tuesday, November 15, 2005

Lesson of Java date and time classes

It happened so that I didn’t use Java date- and time-related classes for a long time. I didn’t like them, and I was lucky enough that I didn’t need them, too. Well, sooner or later that should have happened – today I needed to use some date arithmetic. I opened the Javadoc, and spent next half-an-hour trying to understand, how these classes should be used.

I succeeded, and the result was not as ugly as I expected. The question is, why these classes are so counterintuitive and overcomplicated? I had to use 3 different classes to do a relatively simple thing: Date class to store date in milliseconds; Calendar class to perform arithmetic; and SimpleDateFormatter class to print the date and to parse string input.

There are many classes, they are complex – but still some of the most mundane tasks are not that easy to do. How difficult is for us to answer a question: “What date is the next Saturday?” Easy, right (if we have calendar at hand, of course)? Then try doing it using Java classes. Yes, it is possible – and not that difficult – but, still, it is much more complex process than it should be.

The lesson here is simple: create fa├žade for complex classes so that simple common tasks can be easily done – and for more challenging things (what if I need to print a Hebrew calendar in Klingon?)  there are always more powerful tools.

Friday, November 11, 2005

Sony's DRM malware and Well-Mannered Software

Today I’ve stumbled upon a very interesting article called “Sony, Rootkits and Digital Rights Management Gone Too Far” . The story is simple: a DRM software coming on a musical CD produced by Sony behaves exactly as a malware program: it silently installs on a PC, hides itself from the user, intercepts system calls, monitors running processes and provides no way to uninstall it. I do not want to discuss now how methods like this should attract users to buy legitimate CDs – though I personally will never ever buy a CD with that kind of protection.

I want to discuss another thing – a concept of  “well-mannered software”. The idea came to my mind when recently I was installing several programs on my PC. All of a sudden my firewall told me that the installer wants to connect to the Internet. There was no reason why the installer was supposed to do it – it never told me about “looking for updates” or “downloading additional components”, so I blocked the connection. Surprise, surprise – the installer didn’t complain about that, it just quietly completed the installation with no error messages. Well, actually, it quietly made an attempt to make something run on startup, which was detected by SpyBot, and also forbidden by me. The same happened with other programs I’ve installed – I just had to sit, watch the installers and keep slapping their hands when they tried to do something they were not supposed to.

It seems to be the current state of things: the software considers itself to be smarter than the user, and doesn’t bother to tell the user about its actions. If a computer can be considered as a house for the software, then the user is its landlord, and the applications are tenants. So now the tenants run the house, and the landlord is pushed aside. This makes some people angry, some people miserable, and it definitely makes all of us very insecure.

So, here I suggest the new trend, the new direction – “Well-Mannered Software” (WMS).
WMS should follow just one simple rule
WMS should not do anything, which is not necessary for its normal functions without explaining the action to the user and getting the user’s permission.

An installer should not go online without telling the user “I am going to check for updates – will connect to the site Is it OK?”

An image viewer should not add an item to your startup sequence without asking “I will install color manager to run on startup. OK?”

And a music CD should not install a poorly written piece of malware on your computer without…. No, it just shouldn’t do it at all.