Wednesday, September 12, 2007

Converting to Guice, easier than I ever imagined.

I've been working the past month on revising the data layer of Timepedia, which has, shall we say, somewhat interesting storage requirements. However, the RDBMS related portions had become an enormous eyesore, with tons of handcoded hibernate DAO methods. I have been admiring Guice from afar for awhile, but delayed the pain of refactoring the RDBMS code until I had no choice.

Surprisingly, there was no pain at all!

I took a chance, and used Wideplay's warp-persist framework for Guice, deleted all of my DAO implementation classes in favor of Dynamic Finders, and wrote one Guice module (5 lines of Hibernate config code mostly), compiled, deployed, and prayed. Amazingly, it worked the first time. I was done, total conversion time: 30 minutes.

Now, it helps that I wasn't using Spring nor J2EE (I dislike bulky over designed frameworks with hideous XML configurations), but I think this is a good result for Guice. It reduced the number of lines of code (especially the Dynamic Finders) dramatically as well as the amount of configuration.

-Ray

2 comments:

Kevin Bourrillion said...

This is so wonderful to hear. Just one of the things that makes us feel proud of our little baby. Hey, I don't suppose you could use some of the time you saved to come over and help me with the dishes, could you? That would be great.

Ray Cromwell said...

It's always a joy when your coding consists of massively deleting a whole bunch of source files that really served no other purpose except for boilerplate, and replace them with a simple (and more type-safe) system, and a few declarative constraints.

It's spring cleaning made easy and refreshing. :)