Member-only story
How to Make Your Solution Architecture Unbreakable in C#
Not a Medium Member? Read here for free.
In this article, I want to draw attention to an easy approach to enforcing software architecture in multi-layered C# solutions. A Ulysses pact if you will, that keeps you and your team from layer leaking. I won’t use any 3rd party library just an underestimated feature .NET already possesses.
Disclaimer
Friend Assemblies should be used with caution and in the right context. While it is, in my opinion, a great solution for big monolithic (or module-lithic) solutions, where refactoring the assembly design itself is not an adequate option, it can lead to bad practices if you use it on green field projects. You can read more about that and other alternatives here.
The Problem
Using DDD or other multi-layer software architectures in a big software solution can be hard to maintain over time. New projects get added to the solution and entropy grows and grows. The code might get more and more confusing and the architecture harder to understand. One dark rainy day a developer might ask themself:

And that bearded old man who designed the architecture might not be there to prevent such a mistake. Then as the broken window theory suggests, it’s getting even worse from here and…