.NET
The Best Way to Validate Your Settings in .NET (via Nick Chapsas)
Nick goes into how to create and interact with application settings/options, then shows the problem with options being validated much later than expected. There is a ValidateOnStart option to ensure things work as the app started. There’s a Validate() method that allows you to inject other logic — e.g., not only should this be an integer, it should be between 1 and 10. ValidateDataAnnotations() has the app look at attributes on properties — e.g., Range(1, 10), EnumDataType(…) — which gives you more helpful exceptions. There’s also a Fluent Validations NuGet package to get even more control, however there’s a bit more setup/complexity involved.
The List Best Practice that .NET 8 Makes Possible (via Nick Chapsas)
When returning an empty list, some would argue that return new List<T>(); allocates memory unnecessarily. There is Enumerable.Empty<T> and Array.Empty<T>. In .NET 8 there’s a version of this for read-only collections: ReadOnlyCollection<T>Empty.
How to use Discriminated Unions Today in C# (via Nick Chapsas)
Check out the OneOf package on NuGet. This allows you to have a method that returns one of several return types — for example, an instance of a class, a not-found class, or a validation-error class. This allows you to have a method that returns different types. The video shows how you would use the result of the OneOf type to handle things correctly on the controller side.
Project management
How Frank Gehry Delivers On Time and On Budget (via HBR)
- Make sure you have the power to deliver what you’re accountable for
- Always ask why
- Simulate, iterate, test
- Think slow, act fast (my take is that this may be more applicable for physical projects where the cost of change is higher)
Risk management
Research: How Risky Behavior Spreads (via HBR)
Businesses try to find the balance between minimal risk taking (usually leading to lack of innovation) and being too risky. “In effect, ‘cutting corners’ — even if it’s accidental to begin with — will lead to more corners cut going forward. When things work out, we tend to ignore or discount our good luck, and so the behavior or process no longer feels as risky to us.”