Methods & Tools Software Development Magazine

Software Development Magazine - Project Management, Programming, Software Testing


generjee - Striking New Paths with Source Code Generation

Alexander Derksen, @generjee,

generjee is a free online tool that generates source code of data-oriented applications according to an entity-relationship-model and a user-defined application design. The created code is intended as scaffolding to efficiently start new development projects from a prepared working code base. The produced output is technologically based on Java EE, JSF, PrimeFaces, Apache Shiro, and JPA (e.g. Hibernate) and is ready to run on a Java EE application server or a microservices platform.

But this is not just another code generator. generjee is based on new exciting ideas for code generation that are available for all programming languages and technologies. So if you are not from the Java EE camp, please do not stop reading this article now. There are language independent concepts for efficient software development described in the second part.

Web Site:
Version tested: 1.0
System requirements: Internet Browser
License & Pricing: Use for free. Generation templates are Open Source.
Support: Contact directly via or mail to info(at)

In contrast to most other code generation tools, there is no need to install any software on the local system to work with generjee. The generated sources are provided for free and available for immediate download. To show how generjee works, let us model a very simple product catalog that is represented by the following simplified diagram.

To start this project with generjee, go to the web site and click on "Start a new project". This will start the generjee tool with an initially preconfigured application model.

For this exercise, instead of going step by step through the tool and entering our settings, letís be a bit comfortable and import a prepared example. To do this, just click on the Import button, select the Product Catalog Example, and then confirm with the Load button. This will import the above example model as if you have entered it manually.

On the left side of the tool you will now see the four entities and an additional User entity. The User entity was added automatically, because the imported example has the security option activated. Clicking on an entity will open a page where you can edit the entityís settings and its fields. Feel free to play around and discover the features. Where elements are not self-explaining, there are usually help buttons. At any time, you can restore the settings by importing the example model again. Furthermore, there is the important Project Settings button on the left side. It opens another page where you can define general features of the generated application like the GUI style, the target runtime platform, and desired user roles.

To generate an application code from the entered model, click the "Generate Now" button. After confirming the disclaimer, wait until the generation process has finished and the download of the created code is provided. Download the package and unpack it to your system. Following the instructions in the generated deploy_on_app_server.txt will get the code running. If you do not want to install a server or some missing prerequisites, just navigate to This will open the example application deployed online:

Please explore the Product Catalog and compare it with the values entered in the generjee tool to understand what was generated from our definitions. Please login with "productmanager" (password "productmanager") to get the full functionality access. Let me point out some features worth mentioning:

  • You will see the entities of the Product Catalog in the menu. By clicking on them, you can create, list, edit, and delete entries. The properties of the entities correspond with the fields we have defined in the generjee tool.
  • Users can manage relations between entities, for example, you can assign a category to a product within the product dialogs. On top of that, we can even manage this relationship from the other side (within the categories dialogs) and assign products to an existing category!
  • The access permissions of the entity actions (create, read, update, and delete) are exactly as we have configured them in the generjee tool.
  • Login with admin/admin to get access to the built-in User Management module.
  • Some entity types (e.g. Products) are listed in a Data Grid, while others (e.g. Suppliers) are viewed in a Data Table. This is because we have defined this in our model. For the same reason, the dialogs to create, view, and edit entries are either opened on extra pages (e.g. Products) or within dialog pop-ups (e.g. Suppliers).

Behind the Scenes: New Approaches for Code Generation

Code generators are the tools of choice to build standardized application scaffolds and automatically create development-time-wasting repetitive boilerplate code. Using them right, these tools save time and money while they increase quality and minimize project risks. By using code generators correctly, the development teamís activities can be focused on implementing business requirements rather than writing technical boilerplate and integration code.

Nevertheless, we see that source code generation is not easily accepted in practice and faces quite a lot skepticism and resistance among software experts. Letís resume the current state of the art about source code generation with following thesis:

  1. Doing code generation right leads to greatly improved efficiency and quality.
  2. However, it is very challenging to do code generation right. That is the reason why it often does not keep the promises.
  3. The main reasons, why code generation is so challenging:
  • The high complexity and effort necessary to create and maintain generators
  • The lack of transparency and flexibility while integrating code generation into development processes

The ideas behind generjee take up these challenges and develop new ways to improve the effectiveness, usability, and flexibility of code generation.

For example, one of the main complexity sources is writing generation templates by mixing the target code patterns with the build instructions for the generator. You can simply imagine this as a text-processing document with included field functions:

Software code is much more complex than text documents. So while field functions within documents make them just a bit less readable, generator instructions within code templates increase the complexity greatly. This makes them very expensive to create and understand.

generjee solves these issues with separate templates of clean readable code patterns on the one hand and build instructions on the other hand. Imagine this as an input mask put over the text.

This approach enables handling templates easily and efficiently:

Furthermore, there are more important advantages of this method. It is not only the technical separation that makes it so powerful, it is also the ability of organizational separation. There can be two different developer roles. One role for the target technology expert, responsible for the code patterns and making them clean, and high-quality, while following best practices and specific requirements. The other role is a generator expert who creates the "input masks" and assembles them all together into a powerful tool.

This separation of responsibilities is not only about developer roles, it enables specialization of entire teams and even goes beyond company boundaries!

Another "killer feature" is the reusability of the generator masks to create new generators. This way I was able to develop a PHP code generator from an existing example project within only a few hours, even though I have very limited PHP knowledge. The generator mask of generjee could be reused and adapted very efficiently.

Please remember that all these approaches are independent of Java EE and can be used for every other code language and technology. generjee is just the first project capturing these and other ideas, implementing them successfully, and delivering practical experience and research results.

If you are interested in the mentioned concepts and their progress, please follow generjee on twitter (@generjee) or subscribe to the mailing list on There will be more detailed reports in the future describing the technical and business aspects and new innovative concepts for creating source code automatically and integrating it successfully into software engineering processes.

Related Resources

Click here to view the complete list of tools reviews

This article was originally published in the Fall 2016 issue of Methods & Tools

SpiraTeam Agile ALM

Agile Alliance Technical Conference

SQE Live Virtual Training