Blog
This week I was taught again that you should be thoughtful when applying patterns you read on the internet (which is ironic - because the same applies to this post ;-) ). This time colleagues heavily applied the Creational Design Patterns in Kotlin: Builder from Baeldung. Using the builder pattern in Kotlin in this example is an anti-pattern and in this post I will reason why you’ll end up with safer, less error-prone and less boilerplate when properly applying Kotlins language features instead of this builder pattern.
When working with JPA I prefer generating the primary key on the application and not in the database (check out this post from James Brundege). Additionally, I also prefer optimistic locking and in order to use it you need to specify a @Version
field in your Entity. But you need to be careful how to initialize these two fields. In this post I’ll talk about an error when you assign a default value for both fields in JPA which leads the EntityManager
to never call persist
but the merge
operation instead when creating a new entity.
Last week I reviewed the data design of a colleague. He had to improve a feature and while working on it he noticed that the existing design was not sufficient to properly reflect the changes he had to do. Intuitive he followed the practices of other models in the code and introduced an enumeration to distinguish between different alert types that can be created in the application. Using an enumeration for it is not the optimal solution and in this post I want to describe why you should always question when you see an enumeration in your code and think about solving it with polymorphism instead.
In a project I worked on I saw that nearly every entity and value object was created with Lomboks @Builder. Their reason is that it makes it easier to construct these objects - especially for tests. But it comes with a cost. The problems that these builders create can’t be detected by the compiler and are especially dangerous in every CI environment.
Unit tests had a bad reputation in many teams I worked with. To my confusion I even experienced that a team wrote a hell lot of integration tests but rarely any unit tests. This is contrary to the well-known testing triangle, and surprised me quite a bit. The reason - as I was told - was the experience of the team. “When you change something you have to adapt many unit tests”, was the common tenor. So they decided to write integration tests which call the real endpoints instead. This comes with a cost. Generally you have a harder time to identify where a issue lies when an integration test - which goes through the whole system - fails. Also the runtime will not lead to fast feedback - one of the main benefits of having proper unit tests. I discovered that the issue is that many developers never learned how to write proper unit tests. In this post I will cover the best practices that I developed throughout my career.
Spring Data provides an easy way of keeping track who creates and modifies a persistent entity as well as when the action happened by annotating properties with @CreatedBy
, @CreatedDate
, @LastModifiedBy
and @LastModifiedDate
. The properties are automatically provided by an implementation of the AuditAware
and DateTimeProvider
interface.

About Me

With 1600 attendees is code.talks the largest developer conference in Germany. Around 400 people listened to my talk where I discussed several aspect of robust software architecture design.

What is it?
Rise of Cultures is a simulation game where you guide your civilization through the ages, meet other cultures, conquer continents and built up your cities.
What did I do?
I developed and maintained the backend, which we developed with Java, Spring and Hibernate. When I worked on the project we released it for the first time on the US market to test early retention KPIs.

What is it?
Sunrise Village was a character driven simulation game in which the player built up a village and explored the world with his character. The game featured a rich exploration of the world and an extensive production simulation.
What did I do?
I developed and designed the server from the early days of production with Java, C#, Spring, Hibernate, RabbitMQ and .NET Core. One of the main features of the backend was a .NET Core application that used the same business logic as our client. The backend was capable to simulate multiple players moving on the same map.

What is it?
Gates of Epica was an action RPG developed with the Unreal Engine 4 for iOS and Android. In the game the player fought for loot and glory in more then 600 hand-crafted missions and joined glorious multiplayer boss fights where many players fought a boss for days.
What did I do?
My responsibility was the development of the backend and game logic. We used Java with Spring Boot, postgreSQL and hibernate.

What is it?
Legends of Honor is a massive multiplayer online strategy browser game. In the game you take control over a medieval kingdom and move through the world with your army in real time.
What did I do?
When the project was started I joined it right away as the first backend developer. In this role I had the technical responsibility to design the server architecture and lead a team of 10 backend developers until the launch of the project.

What is it?
As a successor of Goodgame Empire it was planned to target a more casual audience with a similar gameplay. Shadow Kings got released on PC, iOS and Android.
What did I do?
I took over the project in the last months of its existence as the first backend developer. In this time it was my responsibility to lead a team of 6 backend developers and to fork off the server from its origins in Goodgame Empire.

What is it?
Goodgame Empire is a massive multiplayer browsergame with more than 70 million registered players. As a player you build up your castle to rule over four different kingdoms.
What did I do?
I started working on Empire 2014 and was one of the main backend developers of one of the two feature teams we operated. In this project we operated a Java based server which handled thousands of concurrent users with a high amount of requests per minute.