comment 0

Professional Development – 2024 – Week 16

Image Credit: https://www.flickr.com/photos/54585499@N04/

.NET

.NET 9 Fixed Exceptions but Still Don’t Use Them (via Nick Chapas)

  • Although .NET 9 Preview 3 has made exceptions 2-4x faster, using exceptions for business domain things (e.g., email already in use when creating a new account, validation errors) is still not performant. Exceptions are expensive in terms of time and memory because of the extra overhead to capture context.
  • One solution is to use the OneOf type (NuGet package) to implement a discriminated union return type. For example, OneOf<int, object> where if things go well, the int has the value.

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.