Coffee-Driven Development

Brewing Thoughts for Better Code and Stronger Teams

Event Sourcing with .NET and Marten

June 12, 2026 Event Sourcing

The year 2026 began with unusually heavy snowfall in the Netherlands. It was more than we are used to, and in some cases enough to cause buildings to collapse.

I work for an organization that provides Building Information Management services, so it made me think: what happens after a building collapses? There will probably be investigations into the specifications that were used at the time. Do we keep the full history? Do we know whether changes were made, why they were made, when they were made, and by whom?

I had already been looking for a reason to dive into event sourcing, and this felt like a useful example. Event sourcing is not only about storing the current state of something, but about storing the facts that led to that state. That makes it a good fit for systems where history matters.

In this post, I’ll use changing roof specifications as a small example to explain event sourcing, and show how it can be implemented in .NET with Marten.

Continue reading

Arrowhead anti-pattern challenge

update (2019-11-08): added a bonus contribution from Bob, written in prolog

Just recently I had to work on a huge flow-chart to determine farm types based on the animal transports to and from farm locations. I started out with a small proof of concept but didn’t like the way it turned out. I did some research and learned I was basically creating a so called arrow head (“Arrowhead” anti-pattern ).

While it was nothing new, I never knew it was called arrowhead anti-pattern (or arrow anti-pattern).

Continue reading

Retry and fallback policies in C# with Polly

April 18, 2019

In this blog I will try to explain how one can create clean and effective policies to retry API calls and have fallbacks when requests are failing. With Polly it is possible to create complex and advanced scenarios for error handling with just a few lines of code.

This week I was connecting an eCommerce web application to an ERP system with REST APIs. There are multiple endpoints, all authenticated with OAuth. To make sure all calls to the APIs will have a high success rate I had to implement retry mechanisms for different scenarios.

Continue reading