Industry: Public Sector

Clean Code for Reports

Plugin architectures for domain experts require technical balance


Read Story
Image AI generated with Google Gemini

Please note: The English version of this success story was translated using AI to make it accessible to our international audience.

tl;dr

  • Industry: Public Administration
  • Legacy application with reports based on Groovy + JasperReports
  • Modernization for improved maintainability
  • Code stabilization and refactoring
  • Establishing a professional development process
  • Drastic reduction in the error rate
  • Accelerating the implementation of new business requirements

Situation: Application with report extensions

The core of the project was a Java application developed and operated by an external company. This application allowed users to create and export reports based on existing data. These reports (more accurately, report templates) were created, maintained, and published by a department within a government agency.

Until then, these reports were created and maintained directly within the application. Code was exchanged between stakeholders via email. Changes to the code were untraceable. No code history existed. There was no way to view the current version of a code block. The processes and the application’s architecture were chaotic and undocumented. There were no automated tests for the existing code. To test the reports, the code had to be manually loaded into individual script files within the application. This was very error-prone. Furthermore, manually entering the code was very time-consuming.

Reports were created either using the application’s own reports or with JasperReports.

Challenge: Low Technical Standards

There was no traceability of the existing code. External developers found it difficult to understand the existing structure. Access to the source code was only partially possible.

The existing code was also unstructured. It contained many duplicates and some copied snippets from other reports that were not directly related to the report in question.

Report code was monolithic, not (or only dynamically) typed, and therefore difficult to understand. The compiler, as the first line of defense against errors, was absent. Change requests or bug fixes in the reports were lengthy and complex.

For JasperReports reports, the report file could only be built manually. This was time-consuming and error-prone. Exporting existing Jaspersoft reports from the application was not possible. Making changes to the code was difficult. While most reports were stored in a folder, this folder was incomplete: often, files for existing reports were missing.

Solution: Modern Development Practices by the Book + Clever Hacks

As a first step, a modern development environment with version control was established in GitLab. The existing reports were gradually migrated. This made the change process traceable and enabled rollbacks to previous versions.

A custom-built plugin allowed Jaspersoft reports to be generated automatically. It was also now easy to export Jaspersoft reports from the application and transfer them to the development environment.

Introducing unit tests accelerated the test cycles during development—without running the entire integrated application. This saved time and reduced the error rate, especially regressions.

The code was refactored step by step. Monolithic code was broken down into individual methods. The previously dynamic code was statically typed. Unused code sections were identified and removed. This facilitated the extension and correction of reports.

A wiki knowledge base was built in Confluence. Typical processes and technical background information were documented there. This significantly reduced the onboarding effort for new (co-)maintainers. The goal was to ensure that the project could be quickly and comprehensively taken over by others at any time.

Technologies

  • Java
  • Groovy
  • JasperReports
  • TDD
  • GitLab

Contact us