« December 2005 | Main | February 2006 »

January 12, 2006

The Joy of Mighty Mouse

Listen to this articleListen to this article

My tolerance for things (anything) that don't work the way I expect them to is about as low as you could possibly imagine. Just ask my work colleagues about how painful it is to work with me when I have to use Eclipse. (And before the flame wars start, it's not a bad product it just doesn't work the same way I do. In fact after my last blog entry, Jon described Eclipse as well and truly "Opinionated Software". I couldn't agree more.)

So anyway, it came to pass that on Friday 23rd of December, 2005 my laptop died. Yes, my beloved PowerBook just wouldn't start up. (Of course those same colleagues that deride me for my whining about Eclipse also took great pride in cajoling me over my woosey "laptop".) Unfortunately it had apparently suffered one too many falls—about half-a-dozen to be precise—as I made my way around the globe earlier in the year.

Distressed as I was I naturally raced off to the Mac store to hand over the carcass and purchase a new, emergency, computer. Knowing full well that the MacIntel laptops were just around the corner—and being prepared to wait for one— I decided to buy an iMac instead. (Yes, yes. It was a G5 which as of three, count 'em, three days ago has become obsolete.)

As I was wandering around the store waiting for my machine to have 2GB RAM installed, my brother—oh yes, he was with me for moral support :)—started playing with a Mighty Mouse; just like the one included with my new iMac and the same ones that nobody (including me) liked. (I had twice attempted to use one and twice failed. James even offered me his for nix as he disliked it so much!) "Hey! This is pretty cool!" my brother yells across the shop floor. "You have to be kidding me!? Those things suck ass! I just can't seem to get the right-click thing to work!" I replied.

It was true. I had just never been able to get the right-click to work. It was a shame really because I really like the tactile sense of the track-ball thingy; it's almost erotic..ok, forget I said that. Anyway, after explaining my issues and demonstrating my complete inability to operate the Mighty Mouse my brother emphatically exclaims "You're a retard! How can you find it so difficult to use? The only explanation is you're a retard!" Nice. So after some investigation in the shop and after providing much entertainment to the staff as a matter of consequence, he (my brother) deduces the problem: "You're resting your hand on it and gripping" hey says. "Of course I am. How else does one use a mouse?" I enquired. "My arm and hand will get tired if I don't!" I refused to believe that this mouse was any good at all. What a piece of crap. I wouldn't be budged until he said something that really hit a chord: "Think about how pianists hold their hands. They don't rest there entire hand on the keys, just their finger tips and they don't get tired arms." And what do you know? It worked.

The moment I stopped gripping the mouse and instead lightly holding it with my fingertips, the moment I was able to right-click just fine. What's even more impressive is that at the end of a day in front of the computer, my hand no longer feels fatigued from using the mouse all day. Who would have thought? I wonder if the mouse was design in this way purposefully or whether it was sheer luck? Whatever the reason, I now love my Mighty Mouse and what's more, I actually miss it!

January 09, 2006

Databases: A Necessary Evil?

Listen to this articleListen to this article

It's an attitude that I see all too often in developers, especially those that label themselves Object-Oriented Purists who are supposedly capable of precise, rational thought, above and beyond that which we might expect from your mere mortal developer.

Ever since my little rant on the subject over a year ago now I have been tempted time and time again to write something more but each time I go to put finger to keyboard I'm overwhelmed with a sense of resignation to the fact that when it comes to relational databases, most people just don't get it. If I only had a dollar for every time a developer has adamantly told me that foreign keys are a waste of time and that somehow primary keys are a neccessary evil to satisfy the requirements imposed by the database so that we can look up a record. "Why would I need all that nonsense?" they chortle rhetorically, "my application handles all that stuff just fine." Sure it does, so prove it!

What I find even more frustrating is the FUD spread by those I expect to know better. Case in point. I was doing some reading of old Ruby On Rails—yes, my shiny, not so new, toy—newsgroup postings when I came upon this from none other than Mr. Rails himself:

"And let it be no secret that I consider the database a necessary evil for the object-oriented domain model. Not the other way around. Hence, when given the choice between implementations that pit OO model against database purity, I will almost always side with the OO model."—David Heinemeier Hansson

Now the statement just quoted was apparently a justification for Single Table Ineritence and the absence of Mutliple Table Inheritence in rails. Fine. I have no issue with this at all. In fact one of the things I like about Rails is the fact that it is unashamedly "Opinionated Software": stuff works the way it does in Rails because, well, because that's the way someone decided it should. So why shy away from this with some spurious argument about what is/isn't good database design? Why not just admit that it's a personal preference and indeed that's the real reason it's like that? Would you consider Active Record a necessary evil or simply a design choice? I guess it depends who made the choice ;-)

So anyway, let's clear a few things up. Firstly, I'm fairly sure that when he (DHH) says database what he actually means to say is relational database—surely he doesn't mean Object-Oriented Database? Secondly, even though he means to say relational database, what he actually should be saying is SQL database—believe it or not there's a BIG difference!

Admittedly C. J. Date is not the most exciting read for many people but if you take the time to read some of his work on Relational Database theory, you might be compelled to re-consider your notion of the so-called "impedence mismatch" between Object-Oriented Design and Relational Databases:

"... As far as I'm concerned, an object/relational system done right would simply be a relational system done right, nothing more and nothing less."C. J. Date

I found it fascinating when I spent some time at a university many years ago that database theory was the least popular subject. Maybe it's just me? Maybe I really enjoy the subject because I see elegance and simplicity and yet enormous power in Relational Databases and it Just Made Sense™.

Relatonal Databases surely aren't as sexy as Ruby or Rails but neither are they glorified record management systems. They are very precise and provably correct repositories for our data. So, do what you will with databases, treat them as evil if you wish. but I think it behooves us to try and understand what we actually think we've supposedly moved beyond.

Update 18 January 2006: Primary Keyvil, Part I

January 07, 2006

Subversion Gotcha #17

Listen to this articleListen to this article

Ok, so actually it's the first that has bitten me but calling it #1 implies it's the worst one there is and who am I to bestow that honour ;-)

I refer you to this positing in an SVN news group.

It seems that by default, when using Berkely DB with SVN, the default setting is to auto remove log files. Now log files serve a purpose: they allow you to re-play transactions. If those log files no longer exists...no guesses needed.

The rationale for the decision to have this behaviour by default (and I'm paraphrasing): We (the SVN community) don't want people to complain to us with silly stuff like my disk is full. Rather we'd prefer that in the unlikely event of a repository crash, we'd rather that poor sod looses his days work. We made a trade-off between convenience and security.

Hmmm...let me think about that. How often does my hard disk crash? Almost never. And how often do I need to restore from a previous version of a file? Almost never. And how often do I back up my hard disc? Every day. Gee...maybe I don't need a versioning repository?

If I said that at work, I'd be laughed off the premisis. Why? Because a repository is more than just a network filesystem. Moreover, it holds one of my companies major assets: the source-code.

I think I can live with my disk filling temporarily every once in a while versus losing a days work multiplied by 50 developers. In the worst case no one can check in. At least we know there's a problem.

So anyway, this bit me last night when the server on which my SVN repository resides had an NFS failure and corrupted some files. No problem, we can just replay the log...oh they're not there!

One could argue that I (as the maintainer of the repository) should have known about this option and turned it off. However that argument simply doesn't wash as the main argument for turning it on by default in the first place was that most people coming over to SVN won't know enough about how to configure SVN to do the right thing so a choice was made in favour of convenience.

Thankfully, we have daily backups and (in this instance) we only lost two commit sets. So what am I whining about? I'm whining in the hope that this doesn't happen to you under more critical circumstances.

So how about turning that option off by default and putting a big notice in big bold red lettering on the front cover saying "If your disk fills up, it's most likely the logs. Go delete the log files for any days for which you have backups. Leave the ones for which you presently have no backups—ie todays." Not so hard now is it?