Spring on Rails
For rapid prototyping, I’m a fan of “Ruby on Rails”:http://www.rubyonrails.org/, for its lightweight, painfree MVC model.
For large projects worked on by a number of developers, however, Ruby and other lightweight frameworks have limitations. The implicitness that makes Rails so lightweight becomes a challenge as team size increases. (I realize not everyone will agree on this point, but I’m betting there are many who will.)
For instance, there’s no file checked into the source tree that fully describes a model object– I have to browse the database to understand what the object is. There’s also no overall map of all of the pages and associated policies exposed by the application, which is implicitly represented in the filesystem and the source code.
For large scale web development, I like “Spring”:http://www.springframework.org. A single configuration file maps out the entire structure of my web application and the wiring and configuration of the components. At a glance, I can see that a given set of pages has a given security policy. Adding a single line allows me to apply additional interceptors that add new policies.
But Spring is painful for rapid prototyping and iterating because of the frequent need to modify configuration files, rebuild, and restart the application server.
Is it possible to have the best of both worlds? Can we have a rapid prototyping environment that leverages all of our existing Spring investment, and which allows a smooth transition from prototype to production quality code?
We’re currently working a project that we believe will do just this. We have a generic Spring controller, enabled only in development environments, that enables rapid prototyping of pages using the Groovy scripting language for controllers and JSP pages for the views.
I can mock up the presentation by just dropping “foo.jsp” into a directory; depending on the directory I drop it into different sets of standard interceptors are applied (e.g. to require a user login.) I can rapidly prototype a controller behind the page by dropping “foo.controller” into the same directory.
Groovy can import any Java package call into any Java object, so I can reuse all of my existing business logic. Because it’s a scripting language, I can create and modify controllers with the same speed and ease that I update JSPs. Later, I can seamlessly transition to a full fledged Java controller by updating the Spring configuration appropriately; no changes to the view are required.
We’re in the early days of this project, but it seems likely to be useful already. When this is a bit mature, we’ll release it under the GPL for others who are interested in combining rapid development and Spring.