Posts

  • Eliminating NullPointerExceptions in Java

    In C#, nullable reference types must be explicitly declared. For example, a string is not nullable, but a string? is. By introducing this concept, the developer is forced to consider null for any nullable reference. This concept also exists in languages like Kotlin, a modern JVM language that is fully interoperable with Java. Unfortunately, in Java, all reference types are nullable by default. This post is meant to be practical advice for getting rid of NullPointerException in existing codebases.

  • Feature-oriented folder structure

    In many applications the source code is split into the different layers that the application consists of from a technical architecture perspective. For example with a feature1 and feature2, the following could be the folder structure in a simple onion architecture:

  • Current date is an infrastructure concern

    Getting the current date is an easy task in most languages. In Java you can call LocalDate.now(), in C# DateTime.Now or Rust chrono::offset::Local::now(). This seems quite easy to do, so most developers will do it close to where the date is needed. The argument this article presents is that you want to push this code into the infrastructure layer of your code. This applies both to getting the date and time, but for simplicify, the date is the focus.

  • Code smell: Don't talk to strangers

    “Don’t talk to strangers” can be a useful rule of thumb for identifying code smells when writing code.

  • Code smell: Arrowhead code

    A tip for recognising a common code smell is to look for arrowheads. Consider the following python code:

  • The diminishing returns of rewriting a system without the original authors

    Choosing to rewrite an existing system is a big decision. It usually requires a project to reach a point where the technical debt is too much to deal with, or the technology is so ancient that the compentencies no longer exists. However, it can also come from an engineering team that have gone the wrong way, or chosen to rely on a technology that has become deprecated. This particular story is about the later case. It aims to illustrate the two most important takeaways: domain independence and tribal knowledge.

  • Benchmarking EFCore 3.1 Cartesian explosion problem

    In Entity Framework Core 3.1 any LinQ expression is translated into a single SQL statement. This will not be a problem for most queries, but it can cause performance problems if developers are not cautious of this when crafting queries. This article will introduce a simplified model of a performance problem that was discovered and solved in a production environment.

subscribe via RSS