Clean Architecture Example & Breakdown - Do I use it?

preview_player
Показать описание
The Clean Architecture is pretty popular and I've been asked a lot about it directly and indirectly. I decided to take a Clean Architecture Example (Template) and give my thoughts about where I see value in using it, in which context, and what I don't like about Clean Architecture and/or how it's organized, in practice.

💥 Join this channel to get access to source code & demos!

🔥 Don't have the JOIN button? Support me on Patreon!

Clean Architecture Solution Template by Jason Taylor

0:00 Intro
0:24 Clean Architecture
2:07 Template
4:14 Domain
5:41 Application
6:50 Infrastructure
8:05 Abstractions
9:20 WebUI
10:34 Vertical Slices

Рекомендации по теме
Комментарии
Автор

I spent a ton of time following clean architecture like religion and always found its structure needlessly complex. I eventually found myself doing what's implemented in this video and never looked back. Thank you!

chimchim_
Автор

This is a great video. I've been experimenting with clean architecture lately but have never gotten a straight forward example of what it looks like. My current style of implementing it is based off my interpretations of snippets from other posts. What you've described is pretty darn close to how I implement it which is very encouraging and shows me that I'm not just crazy.

The grouping of all the pieces in a single file is interesting to me. I can see how, for smaller projects it might be OK but even that small example you had made that file enormous which might be unwieldy. I definitely think for a larger project, it might be worth it to use a folder for each feature and put each class in it's own file so as to have smaller, more manageable files. Though I definitely see how that can lead to times where you're flipping back and fourth between lots of files when you're working with the whole stack

iankirkpatrick
Автор

Today I've watched about 7 videos on your channel, and I really like your ideas and approach because it is practical and rational. Thank you so much!

tooloudwind
Автор

I find these videos really valuable. Keep going! :)

szuta
Автор

Your videos are awesome!!! Thank you for the amazing real world approach to all things C#!! You take a real world approach which is very helpful compared to 99% of others which take a “proof of concept” approach.

Please keep it up! Been watching your videos all night

goolom
Автор

Thanks for challenging and confirming my ideas on this. I commented the same to Jason re the EF dependency.
One reason for the more hardcore clean approach that I don't see mentioned is that in the same way that correct use of access modifiers "documents" the code, so does it's dependencies.
For this and all the other reasons, having to update an endpoint in one project and handler in another is worth not declaring that aspnetcore dependency in the project with the handler. But I appreciate your unbiased handling of the topic and respect your preference.
Also I think it's worth calling out that all the "outside" dependencies shouldn't live in a single project. I'd argue that orchestration between two third-party dependencies is business logic and should be against interfaces in the application layer. Keeping the implementation of those interfaces isolated enforces that (and encourages code that's more SRP).

johnf
Автор

I was the one screaming use repositories : ))
I think somewhere in the git repo history you can see the full evolution of the template which had repositories as some point. And that's how I still use it in my projects.
Great topic and great video. 👍

foro
Автор

As soon as I discovered your channel, I had to look for this video. Nothing frustrates me more than people blindly following whatever pattern is trending. Thanks for covering this topic.

CambleDCS
Автор

This explanation is really CLEAN. Thank you.

rashedmamun
Автор

I really like your opinion. I've been working on a huge platform and the code got bigger than what I expected and I started looking for ways to improve my architure.
This makes me feel better because I felt bad using my formal architecture for small projects but as you say it’s just fine.
But for this big app I’m talking about I really need a strict separation of layers because later we will be moving to microservices and we really need code that can be easily broken into smaller pieces.

momotesseyannicktidjani
Автор

Physical boundaries nudge developers in the right direction. They create a path of success. If however, a dev really goes out of his way to get his feature working by crossing these physical boundaries then it would be pretty evident for a code reviewer. The bigger the team and the rate of incoming commits the more important this becomes.

alvicstep
Автор

KILLER Analysis!! Well done! I think they have used your feedback to create an improved version

nelsonthekinger
Автор

Personal opinion.
There're a lot of book writers, conference speakers, "consultants" etc who dream to come to you with new shiny architecture which will solve all your problems and bring your product to success (not for free of course). Some of them are balanced, while others force engineers to stop using the _common sense_ and follow dozens of rules just to make it work. That's why we have some approaches where to get 2+2 engineers have to write 300 lines of code to integrate with some framework and guarantee all "principles" are met. Following rules even when you know they're wrong leads to bad quality and slow development.

alex_chugaev
Автор

I feel both strategies work well together. Package by feature and then package using Clean Architecture within those features. However, my C# is very rusty so not sure it's applicable. But great video none the less.

I wouldn't couple UI to the domain though. When the client decides that the UI needs to aggregate results from a middleware abstraction, you end up doing more work. But each project is different and doesn't necessarily fall into the same scope.

lukeyd
Автор

Finally I found a reasonable explanation. Everyone just trying to make us memorize Clean Arch. But no one tells what if I don't need CQRS or something like that?

lastidea
Автор

Wow, finally someone giving a proper analysis to the Clean Architecture. Agree 100% on that Dbset dependency issue and also there's another one that I still didn't find resolved anywhere and that is the isolation of Identity. Having my own User class, how to isolate the domain objects used by Identity without referencing the library? Great video. Would love to see your approach and a concrete example of your solution to my questions.

eContentManager
Автор

Would love a follow up video on using IRepository in the application layer and implementing it in the Infrastructure layer with DbContext and Entity Framework as the Data Source

amirsharapov
Автор

Thanks for this great video, very useful and abstract :)
It is encouraged to make a video about the abstraction of ef core context or the design that should abstract the access to the database in this architecture, with some other than ef.

Keep going!

Thanks, again! +1

eriksp
Автор

Really helped out a ton! Currently using this architecture as well, but been eyeing on the loosely coupled monolith example you made before as it seems a lot easier to take out parts and put it into microservices if it becomes a requirement. As well as the code that should be together, should live together argument.

jessestruyvelt
Автор

First Clean Architecture talk I've seen/read online that acknowledges the difference between Afferent and Efferent coupling, rather than just saying "NO CODE DEPENDENCIES!"

MattOsbun