[.NET Conf 2023] Clean Architecture with ASP.NET Core 8

Rebai Hamida
2 min readNov 26, 2023

--

Description of this session

Clean Architecture with ASP.NET Core 8 | .NET Conf 2023 — YouTube

Clean Architecture (aka Onion, Hexagonal, Ports-and-Adapters) organizes your code in a way that limits its dependencies on infrastructure concerns. This results in much more testable, maintainable code and is ideal for Domain-Driven Design as well as microservices. Learn how to apply it to your ASP.NET Core apps!

Summary

The session discusses the concept of clean architecture in software development. The presenter explains that clean architecture is closely related to onion architecture, hexagonal architecture, or ports and adapters architecture. The core idea is to have a domain-centric approach to organizing applications and their dependencies, as opposed to older methods where the database was the central focus.

The benefits of clean architecture include minimized dependency on infrastructure, which aids in testing and changing software dependencies. It is particularly suited for teams practicing domain-driven design and for applications with complex business logic requiring extensive automated testing. Clean architecture helps maintain a domain-centric focus and uses the compiler to ensure dependencies are correctly managed.

The presentation also contrasts clean architecture with traditional n-tier architecture, highlighting how clean architecture avoids transitive dependencies that make unit testing challenging. The speaker illustrates this with diagrams, showing how in clean architecture, the user interface and infrastructure depend on the business layer, adhering to the dependency inversion principle.

A key aspect of clean architecture is the use of abstractions and interfaces to ensure that the core project (domain model) has no outward dependencies. This structural approach provides guardrails against unintended dependencies.

The presenter then introduces a template for ASP.NET Core 8, demonstrating how to use it to quickly set up a clean architecture solution. This template simplifies the setup of different projects with the correct dependencies.

Finally, the session outlines the rules of clean architecture:

  1. Model business rules and entities in the core project.
  2. Ensure all dependencies flow towards the core project.
  3. Define interfaces in inner projects to be implemented by outer projects.

The core project should contain interfaces, domain model types (entities, aggregates, value objects), and possibly some domain services. The presenter emphasizes the separation of concerns and the importance of abstractions in maintaining a clean and testable architecture.

--

--

Rebai Hamida
Rebai Hamida

Written by Rebai Hamida

Senior Cloud Application Architect, Microsoft MVP in Developer Technologies, MCT, Technical writer, Speaker

No responses yet