The danger of async void
The danger of async void You know those innocent little errors that end up bringing production to its knees? Well, let me tell you the story of how I managed to do just that… thanks to async void. Yes, it was a moment of glory - or not really. First of all, you should be aware that the use of async void is notorious and strongly discouraged, especially in ASP.NET. David Fowler (Architect on the ....
The Generic Repository antipattern
Before we enter this topic, here is a quick reminder of the Repository pattern (the real, non-generic, one), as found in the book Patterns of Enterprise Application Architecture. A Repository mediates between the domain and data mapping layers using a collection-like interface for accessing domain objects. It’s a design pattern that abstracts the data access layer. It’s used to both persist and retrieve data (or entities in DDD) without exposing storage implementation details....
Error handling in .NET Part 2: The Try and the Result patterns
Alternatives to the Exception pattern In my last article, I wrote about the exception pattern. It has great benefits but also great performance implications. Because of these, and following Microsoft recommendations, I’ve also written that we should only use them for exceptional errors. So what do we do when we have to handle an error? Let’s get to it. The “Check and Do” pattern Disclaimer: I’ll include this pattern just for completeness....
Error handling in .NET Part 1: The exception pattern
Exception pattern I had some discussions about exceptions at work, especially for performance reasons: We maintain a platform that has both high volumetry and low latency constraints. The document made by one of my teammates (Hi Olivier!👋) included observations that I didn’t know or that I heard about, but never had the opportunity to verify. This made me want to dig a bit deeper and learn more about this topic. This article is the result of my findings....
Performance comparaison of string concatenation strategies
Recently, I’ve had a conversation with Davide Bellone, on LinkedIn about the different strategies of string concatenation and their relative performance (You can read its post here). His take was that, even though the built-in class StringBuilder is generally the most performant way to concatenate string, it isn’t always the best choice, especially with fewer items. To prove his point, he showed the benchmark he ran with the associated code :...