Home signMedius sign
← Back to Stories

Dynamic queries and unified Javanese code formatting

When it comes to software, the quality of the end product and the ease of use are also affected by the tools and methodologies we use for development. In our recent conversation with our developer Matej Pucihar, we looked at how dynamic queries and uniform code formatting can improve the work of programmers and the user experience. Let's see what we found out.

Dynamic queries

Matej presented an improved approach to building dynamic queries using the JPA - Criteria API and JAX-RS standards, which allows us to be flexible in the use of optional filtering and sorting attributes in the form of REST query parameters, and to optimise the set of data returned by the SQL query. "A unified way to build dynamic queries", as he describes it, means that developers can manage any number of filtering and sorting attributes in a more efficient, standardised and secure way. The OPENAPI definition of such queries is also well-defined, making the API easy to use. This mode is used in almost every table we see on the frontend, which means that the backend provides data according to the filtering and sorting choices the user makes on the frontend.

The library developed by our colleague is used in many Medius projects and allows frontend developers to implement the necessary functionality to work with tables easily. This has improved the efficiency of the development process and ensured that the final product can be adapted to the specific needs of the client. The client can express his/her preferences as to what should be visible in the tables seen by the users, and the developer takes care of the rest using the library mentioned above. The main advantage is high flexibility, not to mention robustness, as the developed code is more readable and easier to test.

Usage limits

Despite its wide applicability, this technology has its limitations, as it operates on top of relational databases and is not designed for the field of machine learning. However, although it has been used mainly on projects that are not "AI in nature", the applicability is still very high.

Challenges of code formatting

In the second part of the talk, we focused on the issues and solutions related to code formatting. IntelliJ IDEA is known as the standard development environment for Java, but its flexibility in code formatting brings certain challenges. The main one is that it is not possible to force programmers to follow a certain style of code formatting, which can lead to non-uniformity and difficulties in reading and maintaining the code. This challenge was not specific to our team, as many teams face similar problems when different members follow different formatting styles.

We have taken inspiration from the practices of other successful organizations, such as Red Hat, and introduced the use of the Eclipse formatter within IntelliJ. We have done this by using the IntelliJ plugin, which ensures correct formatting of the code during development, and the Maven plugin, enforcing the formatting rules in the CI/CD pipeline. This approach allows all team members to use the same formatting style regardless of personal preferences or the specifics of the development environment, leading to uniformity and easier code maintenance. At the same time, it contributes to faster bug detection and more robust applications. Reducing the "cognitive workload" of working with code allows developers to focus on more important tasks, with the added benefit of time savings and improved efficiency.

Looking ahead

At the end of the day, continuous improvement is about improving and doing things better. Seemingly small changes can trigger a wave of positive changes in a complex development process. In this case, it means more flexibility, easier-to-read code, faster error detection, less confusion in processes and, most importantly, a higher-quality end product. Continuous improvement is not only about technological progress but also about adapting to the needs and challenges faced by our clients. This has been our commitment from day one, and it's one that we still stick to today.

Cookie Settings

We use third-party cookies to analyze web traffic. This allows us to deliver and improve our web content. Our website uses cookies for these purposes only.
Copyright © 2024 Medius Inc.All rights reserved.
Facebook iconInstagram iconLinkedIn icon