Icon TP 144

Generating architecture diagrams

Problem

For new projects, it is helpful to create a component diagram for the package structure to quickly get an overview of how the individual packages are connected. However, manual maintenance is very tedious when there are a lot of changes, especially with colleagues who love to refactor and with constantly changing customer ideas.

Can this be done automatically? Sure, but it probably won't be the prettiest solution. What about a bash script that uses search and replace to beautify the resulting file? Ok, but can this be done automatically?

Solution

You create your own code generator. There are several existing tools for this. One is Apache Velocity, a Java-based template engine. It can be used to automatically generate text files and also text-based UML diagrams, such as PlantUML.

Velocity offers the possibility to create templates, fill them with context and save them as a file. For the context, the first thing to be developed is a model, to store all components and the associated relations in. There is now only a little bit of code that must be written around it to parse the information from the existing diagram, storing it in the model and passes it to the template. When parsing, it is possible to specify whether certain packages are to be completely ignored or possibly treated differently.

Beispiel TP 144

Example

A simple template with an associated model could look like this:

Example TP 144
The colored markings illustrate how model, template, and output are related to each other.
TP 144 Visual

Further Aspects

---

Author: Vera Müller / Software Architect / New Business

Cookie Settings

This website uses cookies to personalize content and ads, provide social media features, and analyze website traffic. In addition, information about your use of the website is shared with social media, advertising, and analytics partners. These partners may merge the information with other data that you have provided to them or that they have collected from you using the services.

For more information, please refer to our privacy policy. There you can also change your cookie settings later on.

contact icon

Contact us now