Professional Development – 2023 – Week 35

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

.NET

The Secret HttpClient Feature You Need To Use in .NET (via Nick Chapsas)

  • You can add caching on the HttpClient by creating a custom class that extends DelegatingHandler where you can override methods like SendAsync.
  • From within the handler you can use an in-memory cache for example by looking at the query string.

The Smart Way of Using the Decorator Pattern in C# (via Nick Chapsas)

  • Suppose you have code that reaches out to an external service, and you want to put some resiliency around it with retry logic. Don’t add this to the service, as it only needs to know how to integrate (i.e., doesn’t need to know about resilience). Also, don’t extend the integration class, as that introduces a dependency (which is just as bad as putting resiliency in the original integration class).
  • Have the resiliency service implement the interface for the service. This puts a wrapper layer around the service, effectively decorating it.
  • In .NET 7, you register both the actual integration service and the interface, which itself returns the resilient service.
  • In .NET 8, you can use the keyed services approach to tie the interface to the integration class with a string key, tie the interface to the resilient wrapper (no key), then have the resilient service get the keyed version.

Burnout

Why We Glorify Overwork and Refuse to Rest (via HBR)

This article resonated strongly with me — prefer being busy to being not busy enough, proves our worthiness to ourselves and others, holds off other negative feelings we have when we’re off, workaholism is not only socially acceptable but rewarded (socially, monetarily).

The authors suggest examining how compulsive working is true for you, focusing on sleep and exercise, choosing an enjoyable non-work activity, becoming aware of how you feel physically.