Template Programming for Model-Driven Code Generation

The purpose of this paper is to describe the state of my (not “the”) art of template programming. Template programming for model-driven code generation needs to be placed in a context, therefore we describe a small model-driven generative software development project. We show how to implement a simple meta-model into a modeling tool and how to define an application model using this tool. Then we show how templates can be developed to generate meaningful code for the application. We look at the two most popular template languages: Velocity and JET. In the spirit of contributing best pratices, we describe at the end of this paper some issues we have encountered in practice while developing code generation templates.