Menu

Clean Architecture, DDD, SOLID: acronyms often quoted, rarely explained. Behind them lies a simple idea. The business comes before the technology. We have applied this idea in several settings: at an insurer, on a payment integration and on an internal tool. Here is what it changes day to day.

The business at the centre

Domain-Driven Design starts from one observation: the most valuable code in an application is the code that describes the business. An insurance policy, a claim, a payment. These notions have rules, and those rules should be readable in the code, in the words of the people who know them.

In practice, the business model is a set of C# classes with no technical dependency at all. No database, no web framework, no network call. Only objects, their rules and their invariants. A developer who opens this code should understand the business, not the infrastructure.

Dependencies point inwards

Clean Architecture arranges everything else around this core. You can draw it as circles. At the centre, the domain. Around it, the application’s use cases. On the outside, the database, the user interface, the external services.

The rule fits in one sentence: a layer only knows the layers closer to the centre. The domain does not know that Entity Framework exists. It declares what it needs, for example an interface to save a payment, and the infrastructure layer implements it.

In .NET, this rule becomes separate projects and one-way references. Dependency injection wires everything together at startup. The compiler then becomes a guard rail: a reference in the wrong direction does not compile.

Clear boundaries between services

At an insurer, we designed and documented the microservice boundaries, the domain models and their exchanges. DDD brings a valuable tool here: the bounded context. Each service owns its model and its vocabulary.

The same word can mean two things depending on the service. That is normal, and even healthy. What matters is that the exchanges between services are explicit and documented. A well-drawn boundary stops a change in one service from silently spreading to the others.

Code that reads and tests well

On a payment integration, we wrote the code along the principles of Clean Code, DDD and SOLID. In this field, a mistake is expensive. You must be able to read a rule and check that it does what it says.

A domain with no technical dependency is tested without a database or a network. The tests are fast, numerous and reliable. SOLID, and dependency inversion in particular, lets the tests replace an external provider with a stand-in, without touching the business.

An architecture for an internal tool

For an internal tool, we set up a new architecture: Clean Architecture, with BDD and TDD. BDD describes the expected behaviour in sentences the business can review. TDD has the test written before the code. Clean Architecture gives those tests an isolated core to check.

The three reinforce each other. The scenarios describe the need, the tests prove it, the architecture shields it from technical details.

What it costs

Let us be honest: this approach has a price. There are more projects, more interfaces, more files. A simple feature crosses several layers. Getting started is slower than with an application where everything is mixed together.

DDD also takes time with the business. You have to listen, rephrase, agree on the words. That time does not show in the code, but it is essential.

Finally, not everything deserves this treatment. A plain data-entry application, without rich rules, does very well without it. The architecture should follow the complexity of the business, not fashion.

What it saves

The gain comes over time. Changing the database, the framework or a provider no longer touches the heart of the application. A new business rule has an obvious place. A new developer finds their way faster, because the structure tells the story of the business.

The tests become a real safety net. You change the code without fear, because a regression shows up at once. And conversations with the business become more precise, because everyone uses the same words.

Conclusion

What to remember: the business model at the centre, with no technical dependency, and dependencies that always point inwards. It costs a little structure at the start and saves a lot as the application evolves.

On Monday morning, open your .NET solution and look at the references between projects. Does your domain depend on Entity Framework or a web framework? If so, pick one important business rule, move it into a class with no dependency and write its first test. A .NET project to structure? Write to us.

All articles

A project, an assignment, a question?

Describe your context in a few lines and we will get back to you promptly.