Loading...

Latest Posts

Clean Code November 1, 2020

Favor Polymorphism Over Enumerations

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.


Clean Code May 14, 2020

Avoid Inconsistent Builder With Lomboks @Builder

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. Let’s look at an example. This is our object that uses the builder for construction:


Clean Code March 6, 2020

Best Practices For Unit Tests

The best practices I share in this post are ones I followed for many years. However, today I take a more critical view on them. Especially the heavy use of mocking and the definition of a “unit” as the class under test can lead to unnecessary coupling. You can find my updated thoughts on this topic in my newsletter: “A ‘Unit’ In A Test Is Not The Class Under Test” .


JPA January 28, 2020

Additional auditing with Spring Data JPA and Hibernate

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. Beside this common auditing information in my current projects some entities require storing auditing-information about crucial state-changes like soft-deletion. Previously we had to fill the properties ourself:


Continuous Integration January 22, 2020

How To Load A Shared Library From A Subfolder In Jenkins

I work with Jenkins Pipeline for three years now and one pain point is proper isolation of shared functionality between pipelines but even steps. In our repository we defined multiple pipelines and some are that large that we share functionality within it. Jenkins offers the possibility to create shared libraries for that purpose. But unfortunately it’s not possible to load it from the same repository. Since many of the changes in the pipeline are related to a change of the shared library it was tedious to match the branches and versions to be backward compatible.


Top