Friday, May 28, 2010

Spring Roo

Part of RoR's appeal is how a little bit of tooling can generate the boilerplate code that's typical in most web applications.

Spring has developed a tool/framework called Roo as a kind of response to Rails.

There are two parts to Roo: a shell, where in you type commands to modify your projects; and the resulting code it generates into your project.

They get away from the problem of generating and somehow syncing code by using Aspects. Roo generates .aj files with the associated code that it wants to add to your classes. For example, an Entity class should have accessors for each field in the class as well as a finders. Roo adds this code to your class by generating Aspects on your class.

You can inline those aspects using Eclipse's refactoring (Push In..., I believe is what it's called).

Aspects seem to be a nice sweet spot for Java: it allows the side-by-side coding (programmer maintains one code base and the tooling adds to it) while allowing you the flexibility to jump away from them.

http://www.springsource.org/roo