Over the holidays, we will repost the top ten most popular blog posts of the year. This is one: When “code generation” is mentioned, usually everyone thinks about “Model Driven Development”. MDD is a “Model First” approach and it implies that a model has been designed at the beginning of the project. Different kinds of models can be used as input for the generator, but very often a classical UML model is used. Obviously in MDD the model is fundamental. This approach is a good solution if you have enough time and resources to design a reliable an accurate model, and while you continue to use the model as the reference in the development lifecycle. However, it requires a significant workload. Hence it’s a long term and strategic choice.
Another option is to try to generate the code from an existing database. In this case, the database structure (tables, columns, etc) is used as the unique source of information by the generator. This is a “Database First” approach. It has been made popular by Ruby On Rails. It’s known as the “scaffolding” principle and it’s used with different languages and frameworks (Ruby/Ruby On Rails, Groovy /GRAILS, PHP/CakePHP or Symphony, etc..). Hence, it’s very efficient and it allows a rapid start without any model design. With such a tool, you can start your project very quickly. But there are some limitations in this approach… The tool must work with what it has and nothing else… And it doesn’t have a lot of information. So this approach is quite limited. It can be considered as a tactical choice. So, do I have to choose between a too heavy approach and a too limited one? Another approach can be considered, it is based on a mix between the “Database First” and the “MDD”. The principle can be described by 3 steps :- An existing database is used to create a “lightweight model”. The structure of the database is retrieved by the tool as in a “scaffolding” principle but to create a simple model and not to generate the code immediately
- Once the model has been created, it can be updated and complemented in order to provide exactly what is expected for the code generation
- Finally, the customized “lightweight model” can be used by the tool to generate the code (usually by applying templates)
Hello Laurent, Good. why not providing us with the name of the tool supporting . isn’t it Telosys ? too shy… 🙂 !