Welcome to the 68th Edition of The Catch Block!

Baseball in hand and glove. Throw. Baseball equipment. Sport. The game. Advertising. Place for an inscription. The close plan.
EXCEPTION CAUGHT! Photo by Diana Polekhina / Unsplash

In this edition: a new Source Generator for System.Text.Json; the age-old "clean code vs performance" problem; DDD and refactoring; a one-day conference all about F#; who owns your work email; and excellent debugging in VS Code.

C# Source Generator for System.Text.Json

The .NET team is putting out a new C# source generator, and this one is specifically designed to work with projects using System.Text.Json:

Try the new System.Text.Json source generator
Learn about the new System.Text.Json source generator

Why bother with this? The blog post spells it out like this: the current method by which System.Text.Json can serialize .NET objects into JSON relies on reflection, and consequently has all the drawbacks of that (including, among other things, that when used with many objects reflection can be very, very slow).

According to the blog post, the new source generator shifts the inspection of the serializable types from reflection to compile-time, removing the "warm-up phase" required by the reflection mode.

At any rate, check out the blog post; I have a feeling that for JSON-heavy scenarios, this source generator will be a big help.

Clean Code vs. Performance

Davide Bellone tackles this age-old problem in his latest post:

Code opinion: performance or clean code? - Code4IT
In any application, writing code that is clean and performant is crucial. But we often can’t have both. What to choose?

His basic question is this: to what extent should we favor clean, readable code over performant code, and vice-versa?

Long-time readers will know which side of this divide I fall on: I always favor clean code, until and unless performance becomes a problem. To me, programs are written for people first, and computers second.

This article is for paying subscribers only

Sign up now and upgrade your account to read the article and get access to the full library of articles for paying subscribers only.

Sign up now Already have an account? Sign in