Hi all,
This is my first blog article so I'd appreciate your feedback, you can find me on Twitter / X. I was hoping to touch on more subjects and in a more detailed way but I'm surprised by the time it takes to write. Something I hope I will be able to improve in the future.
Article
For several reasons you might need to construct types that need different implementations. Usually you want to keep the implementation details away from the consumer of that type.
In case of C# this usually implies an interface with multiple implementations. Initially you can start with some basic functions where the first parameter is the interface. However, this might not scale or can become verbose. Especially when actual state is involved and other cross cutting concerns e.g. connections, caching, logging.
Some examples of types where this could apply are:
- Abstract Database Service that needs a live connection while deployed and uses lists for tests
- Api client implementations where there's an API rate limit that must be kept track of