Andy McKay

Nov 12, 2007

When to rewrite

I've got a bug in my Rails application, well actually a few of them. It allows you to browse and administer users in an LDAP tree. Yes, the first time I was confronted with this, I asked "hasn't this been done already?" The answer was: "not well". So it was written as a Rails app. A while back I had to trip through this application and it was hell.

We put this application onto another site at Blue Fountain and sure enough it failed. It's not doing the job. So on my commute I rationalised why I'm going to throw that Rails away and start again. Here's my list:

  • Was the developer so damn clever doing X, Y and Z that he forgot some mortal might have to maintain it? Does the person now maintaining not have super ninja Widget Fromboid foo? Was there any code documentation or comments? Was this just a developer getting high off being so damn clever?
  • Is it reusable? Are you going to get rich off maintaining this thing? Is it really just going to start dragging you down time and time again? Is this write once and maintain until you can run screaming away from the compamy?
  • Does it have automated tests of any kind? Unit tests, integration tests, browser tests anything, this is the 21st century right?
  • How many bugs has it had, has it got some now, are those bugs hard to solve than the Middle East peace process? You can tell the death march of a project when banging noises are made on developer's desks and the walk round with a dull glaze and red mark on their forehead.
  • Really how hard would this to be replace? Remember everything is a) easier the second time and b) way harder because of all the undocumented wierd edge cases. Every developer will tell you a) and every project manager will roll his eyes and say b). The answer is really c). I'm not sure where that is but you'll find out.

In this case:

  • I've tried and when you start messing in the Active Record internals you know something is wrong.
  • Nope, we've seen this already. Further the UI is tied into the back end nice and tight. This is actually a useful library.
  • Yes it does, but they don't work.
  • Lots and still hasn't got created confidence, having problems with scaling and leaving file descriptors open all over the place.
  • Not hard, honest no edge cases. All the edge cases work around LDAP or Active Record.

So tommorrow its moving to Django. I reserve the right to amend this blog post to change all the above to justify this change.