March 29, 2010 by huionn
Nowadays, software development is getting more complicated. Many IT business organizations are looking for "Silver Bullet" to cut down complexity and improve productivity significantly. Because of this, source code generation is rising in popularity because people think it can give big boost in productivity.
In general, there are two methods of code generation:
- Model-Driven Architecture (MDA) based code generation – source code is generated from models defined in graphical UML or textual XML. OMG is advocate in MDA. The models tend to be language agnostic and implementation independent.
example: HL7’s RIM is defined as models. Source codes in specific language can generated with its toolsets.
Personally, I think this kind of code generation is not programmer friendly. Unless the model is static (no change to attributes of models during development), it is hard and tedious to keep models consistent with codes. In addition, generated codes are untouchable as it will be overwritten in next round of code generation.
- Domain-Driven Framework/Platform which is popularized by Ruby on Rails. By using RoR, a developer can setup a blog site in minutes (video below). There are a few Java frameworks use similar method (scaffolding) to generate web controller and view for CRUD operations from domain classes, such as Seam, Spring Roo and Grails. Some others use reflection to render user interface during runtime, such as Naked Objects and Trails (with customizable template). There are some others like RomaFramework and OpenXava. Most of these frameworks have similar demo video to setup a website in 10 mins or less.
After some reading and trying, I decide to choose Spring Roo as next development platform (if I am given the authority to do so). I like its vision:
Roo’s mission is to fundamentally and sustainably improve Java developer productivity without compromising engineering integrity or flexibility.
Its flexibility is achieved through AspectJ’s powerful inter-type declaration (ITD) which is very innovative in my opinion. Although it is relatively new, version 1.0.2 was just released months ago, it already has rich set of features. I particularly like its included functionalities:
• Standard MVC web application with JPA entities etc
• Spring Security usage, including login page customisation
• Sending emails via SMTP
• Testing both via JUnit and Selenium
• Usage with Eclipse
• Creating a WAR for deployment
However, I don’t like its generated finder page and its menu link. It is not usable for complex domain object which have many properties. If the finder page can be customized by addon extension, then it may worth to invest some times to understand its architecture in depth. Otherwise, if worst come to worst, controller and view can still be customized hand-coded.
Besides productivity, I think using this kind of framework promote consistency too. I will definitely spend more time to learn ROO in this few weeks…