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.
- 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)
![CodeGeneration3](https://labs.sogeti.com/wp-content/uploads/sites/2/2013/08/CodeGeneration3-300x217.png)