Loading...

Latest Posts

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” .


Clean Code November 20, 2019

Boost Your Development With Proper API Design

In this post we’ll go through an example application and see which methods and principles we can apply to build a robust application that is easy to maintain, extend, understand and use. In general, this is a subject with a much larger scope than a simple blog post can provide, so the content is neither complete nor exhaustive, but a selection of topics that I visited recently. We use an arbitrary business case where we can buy and sell resources on a market.


Clean Code June 18, 2019

Never Design A Class That Knows How It's Used

When you design a class you should never design it in a way that the class itself knows how it is used from the outside. Breaking this principle will make it difficult for other developers providing other implementations. I recently stumbled upon an implementation of different entities where the implementation had to provide a unique id for itself. Why this is causing problems and how you better design such a situation I’ll explain in this post.


Clean Code April 29, 2019

Distinguish Between Optional and Mandatory Parameters in the Builder Pattern

After reading through Designing Bulletproof Code by Otavio Santana I stumbled upon its example of using a builder pattern. While this was not the focus of the article itself I also realized that I saw the issue in the past a lot and I ran in it as well. The widely spread understanding of the builder pattern (as described in Effective Java by Joshua Bloch) does not differentiate between optional and mandatory parameters and that makes their usage not easier but harder.


Top