Assertfail

Clean Architecture Comparison continued

18 Nov 2024

Background

A year ago I did a clean architecture comparison for some clean architecture implementation samples online. One of the conclusions was that I did not look into how much each implementation chooses to marry different frameworks and libraries.

Since then, we have seen some updates to existing solutions. We see one solution that has been archived eShopOnWeb, that was deeply influenced by @ardalis, that sample now lives on in nimblepros/eShopOnWeb. Some are not popular enough that it makes sense to keep them in this comparison. In this post we focus on C#.

Overview

Solution Domain/Core Application/UseCases Comments
@amantinband SmartEnum, error-or, MediatR, throw FluentValidation  
@ardalis SmartEnum, SharedKernel, Specification, Result, GuardClauses, MediatR  
@jasontaylordev MediatR EF, FluentValidation, AutoMapper database framework dependency
@kgrzybek MediatR Dapper, FluentValidation database framework dependency
@ivanpaulovich/clean-architecture-manga     Not updated

If we summarize this table we can note that some of the very popular solutions are dependent on database frameworks in the application layer. Having a database framework dependency is generally frowned upon in Clean Architecture.

Libraries in use

Many of the popular implementations take a dependency on popular libraries by @jbogard:

amantinband introduces:

@ardalis introduces:

These libraries are lightweight in that there is not much code or functionality in them.

We still note that many choose to include such libraries in the domain and or application-layer.

Conclusion

We see that at least one popular implementation called clean, choose to marry Entity Framework. Most of the implementations choose to include libraries. I would argue that marrying EF is something you need to be very much aware of in a Clean Architecture context. It can still be called clean, though with the addendum that it marries EF. We have a spectrum of clean depending on what is practical for a team to implement. I interpret this as, that there are missing patterns or language features for C# that makes mainstream implementation of Clean Architecture more of a chore.

Some of the libraries such as Result, SmartEnum and ErrorOr are needed because of missing language features in C#. These libraries are not needed in an F# solution.

Tags


Comments

Do you want to send a comment or give me a hint about any issues with a blog post: Open up an issue on GitHub.

Do you want to fix an error or add a comment published on the blog? You can do a fork of this post and do a pull request on github.