I made a change in the blogger configuration to ease the later work when blogging. It is possible that older entries are not correctly formatted.

Friday 4 March 2011

Code Generation

Since my last project, I gained much interest in code generation. The application we were supposed to reimplement using GWT consisted of around 60 entities and had as many dialogs to be implemented. Moreover, the database schema we had was in german. Since we did not want our code to be a mix of English and German, we needed to create a lot of typical classes for this: entities, DAOs, business logic, service layer, controller as well as more or less straight forward dialogs.

Since I did not have any of my usual tools, I decided to create my own generator, which could generate simple (still to be edited!!!) versions of the diverse classes we needed. This went quite well except that I needed to write java code to perform these actions. So the first generation was somewhat of a procedural code generator. This was a tedious task which made it quite difficult to maintain the code in the always evolvin software infrastructure we had.

A more useful approach is template generation. However for templates to be adapted for such a task you need a template language capable of looping over fields and methods of the code model.