Code-Held

Blog about Spring, Kotlin, Java, JVM, Clean Code, Continuous Integration and many more topics from my daily work

Code on screen dark

In many (JPA) applications numerical ids are chosen for the surrogate key of the entities. But how do we make sure that they are not used twice? In a scenario where our application needs to scale horizontally we need a solution for that. Most developers come to the conclusion that the database should take care of that. But this is a fragile solution and in this article I want to discuss it.

Did you work on the task to integrate Spring Security in a project? If yes you probably stumbled upon the decision which PasswordEncoder to use. I saw many developers actively researching that question and deciding on a concrete algorithm. In one project we even choose a less secure decoder - for performance reasons. Don’t. Just don’t! Don’t choose a weak encoder for performance. Actually, don’t choose at all! Let Spring handle your security.

Personal development goals in software engineering are not trivial to define. In general, goals should be SMART (Specific, Measurable, Achievable, Realistic and Timely). But in reality our field of expertise is that diverse and complex that it is not as easy to find those goals like in other professions. For someone working in the sales department a revenue goal is easy to define and to decide whether he succeeded or not. For us software developers it is different. In order to improve we need abstract goals that are independent enough to survive in our agile day-to-day business. I received many goals in the past, and a lot of them felt wrong, unfair and not helpful for my personal development. For my employees I took another approach. The overall goal needs to be to enable your colleagues and in this post I describe how I achieve that.

JPA entities have a couple of pitfalls and consequences when handling them in your application. Especially understanding how JPA manages and synchronizes the state of an entity is essential to avoid unexpected behavior. This can be unintuitive when passing JPA entities as method parameters in Spring Data in- and outside a transaction. In this post I will explain a best practice when working with JPA entities and when it’s okay to pass it through method parameters and when you should avoid it.

In recent reviews I stumbled upon extension functions which didn’t quite felt right, but I wasn’t able to determine where that gut feeling was coming from. After seeing quite a lot of them I came to some conclusions why that’s the case, and I gathered rules for me when extension functions make sense to use and when they should be avoided. I discovered an overuse of the language feature - something you often experience when you work with a new fancy language with nice features. In this post I’ll share my thoughts.

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.

Code on screen

About Me

Picture of Marcus Held

Marcus Held

IT Backend Consultant

It is my passion to support difficult backend projects. With more than 15 years of experience in software development and the last 12 focused on the JVM with Spring, I help companies to identify the critical points in their project and correct them in a sustainable way.

Prior to my freelance work I managed the backend department at grandcentrix with more than 30 employees. There I was involved in developments like Modbus Cloud Connect or in projects of customers like Brose, Bucher, Gardena, Hörmann, Miele or Migros. As a software developer I was responsible for the development of several online games like Rise of Cultures, Sunrise Village, Goodgame Empire or Legends of Honor with up to 220 million registered users.

At the age of 12, I had my first experience with programming. At 15 I started working professionally for companies and by 18, prior to finishing school, I founded my first company: Web as Art.

  • (k)lean JPA — Fallstricke und Clean Code mit JPA & Kotlin KKON digital 2021

    150 Kotlin enthusiasts throughout Germany attended the KKON 2021. In my talk I described pitfalls with JPA and how you avoid them in kotlin.

  • Boost Your Development With Proper API Design code.talks 2019

    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.

more_horiz
Rise of Cultures
Rise of Cultures close

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.

more_horiz
Sunrise Village
Sunrise Village close

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.

more_horiz
Gates of Epica
Gates of Epica close

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.

more_horiz
Legends of Honor
Legends of Honor close

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.

more_horiz
Shadow Kings
Shadow Kings close

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.

more_horiz
Goodgame Empire
Goodgame Empire close

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.

Technologies