tisdag, december 13, 2005

Homegrown DAO to Hibernate to Rails.

We have an internal project called ITDoc, which should be used by the IT department to document internal resources. This system was created a few years ago by me, with a quite complex database, strange homegrown DAO and a very nondeterministic homebuilt cache. As always the prototype became the system and now we sit here with code that really don't scale and crash way to often.

But due to lack of resources (and time) we can't fix the code right now. So I had the idea that I would try something not-so-radical. I remodeled the database into a better shape, cut away all the DAO and cache code, and I had myself some model objects ripe for hibernation. But after I begun writing some xml definitions I found my mind drifting and thinking about how I would convert the old database to the new format. And the xml-writing went slow, even though it was light years faster than writing DAO code from scratch.

Enter Rails. I decided - after making sure that the hibernate approach could work - to write a spike in Ruby instead. Said and done. After an hour I had a rudimentary migration script written with ActiveRecord. Since the data model was quite complex this was the hardest part to write. But after that was done the Rails writing went extremely easy. In one hour more I had the basic functionality that was so hard to actually manage in the original system, and the code was probably less than 50 lines long.

But now comes the decision time, when other people decide which approach to choose. Since I'm not going to be doing this project it's not sure the choice will be Rails. Even so, it was an interesting endevour and I once again reinforced my opinion that Ruby is a fun language to write in.

Inga kommentarer: