Heterogeneous Rails Applications

Posted by Jeremy Voorhis Mon, 17 Apr 2006 21:49:00 GMT

Or, Don’t be afraid to use the right tool

At Canada on Rails, I showed screenshots of a recent PLANET ARGON Rails development project which showcased my work with Globalize. What the slides did not explain was how we were able to process 1000s of images in an agile way.

We began by writing our own plugin, similar to FileColumn. Problem is, each image we had to manage required up to 4 variations, as well as transport the files to a bandwidth provider. In the beginning, the rules to produce these variations changed frequently. As you might guess, our models had suffered some bloat. My solution to coping with this problem was inspired by Jason Watkins’ experience in the video game industry: an asset compiler. In short, an asset compiler is a build tool that works from raw assets living in source directories and transforms them into their final state.

What I wanted was a flexible tool to regenerate – or build – all of these image variations, and I wanted it to stay out of my way. I had decided the best platform to build this tool might be Rake – a Ruby build system. I followed Jim Weirich’s RDocTask library as a template, and in a couple of days I had the asset compiler up and running. With the asset compiler in place, it was a simple matter to write an observer to fire off the right tasks. Our plugin and our image models were greatly simplified and now it simply saves or deletes a file in a source directory.

There is something desireable about heterogenous architecture. Specialist components with clear lines of responsibility become a joy to work with, and easier to maintain. Don’t force heterogenous design, but consider it as an agile approach when you suspect your application is growing into a monolith.

Comments

(leave url/email »)