Mostly Harmless

Tuesday, July 10, 2007

Moving!

I'm moving this blog to it's new home at http://www.anoopjohnson.com

Sunday, May 13, 2007

Weekend Hack

Wrote a Splay Tree implementation for Python, code is here.

Labels: , ,

Saturday, April 28, 2007

Moving From Google Bookmarks To del.icio.us

I've been using Google Bookmarks for a while and was missing a few features which were important to me - sharing, public feeds etc to name a few. I wanted to move my bookmarks to del.cio.us, so I wrote this Python script to do the job.

It's a command-line program you can run from your desktop. It will grab your
Google bookmarks as an RSS feed, which is parsed and posted to del.icio.us through their REST interface.

The code lives here.

Labels: ,

Saturday, April 21, 2007

iBATIS Data Mapper - Initial Thoughts

Of late I've been playing with iBATIS persistence framework. iBATIS is a query mapper - it lets you map SQL queries to POJOs (Plain Old Java Objects). The SQL queries and mappings are externalized in XML files.

This is my initial evaluation of the framework. Most of the points are not specific to the framework - it's more of a comparison between a full-blown O/R mapping and query mapping.

The Good

  • Simpler - Smaller learning curve when compared to full-blown O/R mappers.

  • Unlike O/R mapping, your data model does not have to match the object model because there is an additional layer of indirection (that is the SQL) between the classes and the tables. You can manipulate the query to match the object model without changing the underlying table structure.

  • Full power of SQL is in your hands. This means you can introduce multiple tables or results from stored procedures easily. (which is pretty cool.) Also since you're writing the SQL by hand, there is more scope for optimization because you can use your DBMS-specific features like query hints, hierarchical queries etc.
The Bad

  • You still have to write the SQL. (But then you already knew that.)

  • Has no notion of parent-child relationship. One of the great things about Hibernate is the automagic updation/deletion of child records during changes to the parent record. For instance, if you're deleting an Order record, you may want to delete all the order items. In iBATIS, you will have to manage the relationship yourselves.

  • Unit testing will be harder. Automated unit tests should be self-contained - they should not be dependent on external databases or application containers. This is where HSQLDB comes handy. I heavily use HSQLDB and Hibernate's schema-generation tool for unit testing the persistence layer. With iBATIS, this will not be possible unless you ensure that the SQL you write is not specific to an RDBMS. This could be very hard.
When not to use a SQL Mapper

  • When you have full control over data model and object model - it may be a better idea to go for a full blown O/R M like Hibernate.

  • When the application needs a lot of dynamic queries - it may be better to stick with JDBC or write your own framework.

Labels: ,

Sunday, April 15, 2007

Emacs 22

I just now installed Emacs 22 in my new laptop. There are many new cool features I am excited about.

Emacs 22 is still under development, so I expected a few stability issues. But I've been running it continuously over the weekend with a few dozen buffers and so far it has not crashed on me.

I'm yet to try my 2000 line-long .emacs (and a ton of elisp libraries it is dependent on) on Emacs 22. Hope all goes well.

Update: Almost everything worked out of the box except JDEE. Problem solved by upgrading to the latest JDEE version.

Labels: ,