CodeCharta: Visualize software quality clearly as a cityscape
The open source tool CodeCharta makes the complex structures in software projects tangible and helps with reorganization.
(Image: dibrova/Shutterstock.com)
- Andreas Blunk
Improving the quality and changeability of software is often a mammoth task. To make their work easier, developers can fall back on code-specialized tools for code analysis and visualization, such as CrocoCosmos and Seerene. However, these are usually chargeable. The open-source tool CodeCharta makes progress in refurbishment clearly visible – by displaying it as an urban landscape. Large buildings stand for complex code, red ones for missing tests.
CodeCharta was developed by IT service provider MaibornWolff so that people who have no knowledge of code can easily visualize the state of their code base. The company uses CodeCharta for software health checks and modernizations, for example, to provide clients with a quickly understandable picture.
The following article shows how this tool can help developers and stakeholders alike to identify problems, plan solutions and evaluate the success of the measures. A look behind the scenes of a real refurbishment project at Deutsche Bahn clarifies it that visual metrics make software modernization easier to understand and manage across teams.
Software becomes a refurbishment case
Software needs modernization when it becomes difficult or impossible to add new features or change existing ones because new errors keep occurring.
Stakeholders recognize the first signs when features regularly fail and planning is no longer possible. The implementation of features either takes an unplannable amount of time or they require a lot of bug fixing after implementation. This situation occurs when there are
- there are no automated tests,
- the software does not have a modular structure or
- the code is of poor quality.
The aim of a refurbishment is to improve the software so that changes are simpler and less error-prone. This is because over time, new requirements arise that make adjustments necessary. The quality of software is therefore high if developers can adapt the software with manageable effort and no errors occur.
Videos by heise
How does CodeCharta help with this?
The special feature of CodeCharta is the representation of the metrics with the elements of a city that are familiar to many people, even without a developer background. Each file in the code base corresponds to a building. The buildings that are in the same directory are represented as a neighborhood, which is separated from other neighborhoods by streets.
Usually, the visualization of a software starts with the consideration of the following metrics:
- The footprint for the size of a file (lines of code),
- the height for the complexity of the code
- and the color for the extent of test coverage.
With this visualization, various metrics for evaluating software quality can be identified at a glance.
Example of a software refurbishment
Deutsche Bahn, whose software was refurbished by MainbornWolff, serves as an example project to illustrate this. Figure 1 shows the progress of the refurbishment in several steps:
(Image:Â MaibornWolff)
21/04: The city is very roughly structured: There are few buildings, which are also tall and wide. Many of them are red. The color signals a lack of testing and the height of the building's a high code complexity.
22/06: The proportion of yellow and green buildings has increased over the course of the renovation. This means that more tests have been added. Little has changed in the rough structure of the city and the height of the buildings.
23/07: Just over a year later, there is good test coverage almost everywhere (green buildings). There are also many more individual buildings to recognize, and they are no longer as high as they were at the beginning. So the code has been split across more files, which has reduced the complexity of the software.
24/01 to 24/07: This trend continues in the following months (January, April, and July 2024). When comparing April 2024 to July 2024, hardly any differences are recognizable.
The city is mainly green and has a finer granularity. Only in some places are there still tall buildings. These still need to be dismantled for a complete redevelopment. They are still present here because the code is not currently changing at this point and the redevelopment is to take place at a later date.
Apart from the few tall buildings, the redevelopment is almost complete. The question remains whether the division of the city into the structure resulting from buildings and streets is good, i.e., whether a comprehensible modular structure has been created. However, this question cannot be answered with this code map. A way must be found to represent the architectural quality of the software. Architecture rules provide the basis for this.