Тёмный

Clean Architecture with ASP.NET Core 6 

dotnet
Подписаться 303 тыс.
Просмотров 389 тыс.
50% 1

Опубликовано:

 

16 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 210   
@Greenthum6
@Greenthum6 2 года назад
There are two fundamental issues that are often overlooked in these simplified clean architecture templates. First, UI depends on infrastructure. That dependency is usually not visible in charts for whatever reason, but it is there regardless. Secondly, the template uses core entities within DbContext in infrastructure. Now your database structure depends on domain entities. Those will evolve and your database breaks. Keeping database and domain entities separate is very important. I have used clean architecture for sometime, but in my model the core is split further into domain and application layers.
@cheesypufs
@cheesypufs 2 года назад
I agree about splitting the entity models and domain models. However this would be less necessary if you use something like EFCore migrations to ensure your DB is always updated. Although I've never been a fan of this approach, it feels fragile.
@Greenthum6
@Greenthum6 2 года назад
@@cheesypufs I haven't heard anyone using EF migrations in production and suggest nobody to do it. DBAs will not be happy. In critical systems database changes require review before apply. Keeping them in pure SQL is the cleanest approach. DbUp has been a great choice. The main issue with EF here is that it is too easy to spread database details everywhere. With clean architecture, only infrastructure layer should be responsible for database concerns. If there is only one entity through the application then everything depends on everything. Mapping objects is the necessary evil to keep consistency.
@k-ravndal
@k-ravndal 2 года назад
@@cheesypufs The main issue when using the same entity for both the domain and the db, is that you might end up in a situation where the structure or limitations of the database, also limits the way you build you domain. A database is an implementation detail, and should in no way govern the way you build your domain model.
@ApolloJKD1973
@ApolloJKD1973 2 года назад
Exactly! I have the same exact view. I use a mix of Clean Architecture and Vertical Slice Architecture (Jimmy Bogard). There are many videos on this from Jason Taylor such as this: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-dK4Yb6-LxAk.html Basically all the logic is in the Architecture layer either in MediatR commands or Queries. The Application Layer and the Domain Layer combined make up the Core. The Domain Layer does not have logic for the most part. I have always found it hard to accept how putting logic in your Domain Entities is recommended. Other than the basic logic that you can put there (such as date range validations etc), we typically work with very complex logic in our applications and our Entities are used in different ways across the system. Another point where I agree with you is that no matter how much we can say we can swap out database technologies it is not easy to do. You cannot easily go from SQL and EF Core to CosmosDB without changing a lot of code! Again if your system is as simple as each Entity can save itself bla bla bla and thats it maybe you could do it with minimum coding. But that is not realistic. I have EF Core Queries that span entities and are highly complex. Good luck rewritting all that using a different technology easily!
@ApolloJKD1973
@ApolloJKD1973 2 года назад
@@Greenthum6 EF Core migrations do not need to be automatically applied to production. You can generate a SQL script from the migration and have your DBA's review and approve before you run it.
@vincidixit
@vincidixit 2 года назад
Very helpful. Well explained with examples and demo. This will definitely make things easy.
@albxdotcom
@albxdotcom 2 года назад
Thanks Steve...great work again !! I'm enjoying working with Clean Architecture, it doesn't feel like all the pieces are super glued together anymore.
@Ardalis
@Ardalis Месяц назад
Exactly what it's designed for!
@RoggemansG
@RoggemansG 2 года назад
Thank you Steve for all these precious gifts you make for us!
@CodewithFemi
@CodewithFemi 2 года назад
Thanks Steve for taking us through this. I love clean architecture!
@nickfotopoulos5323
@nickfotopoulos5323 2 года назад
| Links from the end of the video | ::Clean Architecture Template:: github.com/ardalis/CleanArchitecture ::eShopOnWeb:: github.com/dotnet-architecture/eShopOnWeb ::Architect Modern Apps with ASP.NET Core and Azure eBook:: dotnet.microsoft.com/learn/web/aspnet-architecture
@vinholiver6801
@vinholiver6801 2 года назад
Thanks
@mattferderer469
@mattferderer469 2 года назад
Links to the Resources Template: github.com/ardalis/CleanArchitecture eShopOnWeb Sample: github.com/dotnet-architecture/eShopOnWeb Architect Modern Apps .NET Azure eBook: dotnet.microsoft.com/learn/aspnet/architecture
@nickfotopoulos5323
@nickfotopoulos5323 2 года назад
Thanks!
@saeedtalib8358
@saeedtalib8358 2 года назад
Thank for the time and help
@Sad-Lemon
@Sad-Lemon 2 года назад
I absolutely love the shirt :D Just started watching :)
@cethrivias
@cethrivias 2 года назад
It finally clicked for me why it is called *Domain-Driven* Architecture
@ebrimasidibeh7587
@ebrimasidibeh7587 2 года назад
Nice one 👍. I love DDD and there is always different ideas among developers about its architecture but having standard template is awesome 👌
@S3Kglitches
@S3Kglitches 2 года назад
this video is extremely useful and people have to realize that it is a more robust extension of three-tier architecture
@caglarad2544
@caglarad2544 2 года назад
Thanks Steve for sharing your valuable information with us.
@jegtugado3743
@jegtugado3743 2 года назад
Awesome presentation. This reinforced my understanding of implementing DDD and Clean Architecture. Thank you, cool template.
@rbp365
@rbp365 2 года назад
Clean Architecture Template: github.com/ardalis/CleanArchitecture eShopOnWeb Sample: github.com/dotnet-architecture/eShopOnWeb Architect Modern Apps with ASP.NET Core and Azure eBook: dotnet.microsoft.com/learn/aspnet/architecture
@Erril_Ferndal
@Erril_Ferndal 2 года назад
Thanks Steve! I really like Clean Architecture
@belmo_
@belmo_ 2 года назад
I didn't know that I needed this video.
@PeriMCS
@PeriMCS 2 года назад
Uncle bob taught me this Clean Architecture about 20 years ago. I thought I will see something new here.
@evgeni-nabokov
@evgeni-nabokov 2 года назад
Who is he?
@ahadporkar7355
@ahadporkar7355 2 года назад
Thank you Smith for great explanation, it's been a great help with Clean Architecture.I understand a bit better now where and how these things are handled.
@omidkarami4312
@omidkarami4312 2 года назад
Hi Steve, thanks so much for the amazing video, what is the best way to contact you for consulting?
@julietchoy
@julietchoy 2 года назад
Thank you so much for putting this up!!
@Gonkers44
@Gonkers44 2 года назад
I really don’t understand the point of the shared kernel project. I understand this was an abbreviated talk, but I don’t think that was covered well.
@steve-ardalis-smith
@steve-ardalis-smith 2 года назад
It's purely a way of sharing (high level, abstract) code between apps. If every app uses the same guard clause extensions or value object base class, or exception base class, this provides a better tool than copy-paste or sharing the same source files for achieving this reuse.
@baolam4180
@baolam4180 2 года назад
Thanks. Great explanation at right time for me 😍
@rodelias9378
@rodelias9378 2 года назад
Really awesome talk! Thanks a lot!!
@yasharaliabbasi5653
@yasharaliabbasi5653 2 года назад
Thank you for your useful topic, How should we add authentication and authorization?
@activoutdavid
@activoutdavid 2 года назад
That's very good question. I suggest that you use standard .NET authentication and authorization and implement Policies that are implemented by calling interfaces in the Domain/Core, probably with help for example a user database from Infrastructure.
@dvanrooyen1434
@dvanrooyen1434 2 года назад
I have learnt from experience, the application/business needs should help drive the architecture and not the other way round. So for example in the industry we do say let’s make sure we have clean architecture so that we can focus the business needs rather than fighting the technology as the application grows. This has merit and is correct, but is too late in the process. Understanding the business need in a ‘clean’ manner will help getting the right architecture in place, which in turn then helps us focus on the business and all that good stuff.
@BabakSekandari-q1c
@BabakSekandari-q1c Год назад
In a different tutorial, I heard that all of MVC in a Core project was the presentation layer and that business logic should be coded in a a class library in a different project. In this tutorial (if I've understood it correctly) the presentation layer and business logic are within the Core project. At time 7:51, it states, "Model all business rules and entities in the Core project." Perhaps some further explanation can clarify this for me.
@shatiswaranvigian9349
@shatiswaranvigian9349 2 года назад
Very helpful, thank you.
@125Jackal
@125Jackal 2 года назад
Steve! How u doin? Just wanted to say that I love your courses in Pluralsight.
@waymanharris1284
@waymanharris1284 2 года назад
#Support #Awesome This is the most helpful youtube video I watched all year.
@UndersVzLOM
@UndersVzLOM 2 года назад
Very helpful. Where can i read more on those repository, it's base class and specifications? Thanks
@nicolasundiano8406
@nicolasundiano8406 2 года назад
if you have constants in a class Roles such as "Admin", "DemonUser", etc and you use it in all layers, where would you put this class? and the same as helpers like PaginationHelper to calculate Skip and TotalPages
Год назад
Constants to the Core project. PaginationHelper to the project where your UI lives.
@viniciusmorgado9722
@viniciusmorgado9722 2 года назад
Awesome content, thank you!
@browaruspierogus2182
@browaruspierogus2182 2 года назад
Any and every company can manage the code as they want and according to in-house convenience standards - this is just another shuffle of someone's ambition or corporate idea that is not necessarily as good as they think
@jez9999
@jez9999 2 года назад
Why is there never an acknowledgement that in order to make "clean" architecture, you introduce massive amounts of complexity? Having to learn all the new terminology for stuff like value objects, domain events, validators, custom guards, etc. and figure out how to structure it all is no mean feat, and is a lot harder and less intuitive that just creating an n-tier application, to the point where an n-tier application is probably the best choice for anything but huge projects. 21:20 Composition root in the web project. I've noticed this before. So much for "clean architecture" stopping the UI from referencing infrastructure; it has the composition root. It has to reference everything!
@Ardalis
@Ardalis Месяц назад
"It's too complex!" but also "You should have added yet another project for composition root!" It's a tradeoff. Yes, you certainly *can* put all the DI/composition root logic into another project, but that only adds to the complexity without adding much value. You can certainly do that if it makes sense for your app.
@francogiulianopertile279
@francogiulianopertile279 2 года назад
Aweesome presentation
@wilfredogutierrez1640
@wilfredogutierrez1640 2 года назад
Thank you for sharing, very useful
@srivathsaharishvenk
@srivathsaharishvenk 2 года назад
This is one way of achieving clean architecture, this is mostly OO based, however in my view there is a much simpler way, Please see Domain Modelling made functional by Scott Wlaschin and thank me later. Everything in there can be done in any language and especially c#. The main difference is it is better not to include any IO related logic (DB, API, email sender, etc.) in the core domain layer as much as possible, even the interfaces
@steve-ardalis-smith
@steve-ardalis-smith 2 года назад
Yes you can certainly achieve similar things in functional languages. This is "mostly OO based" because C# is an OO language.
@srivathsaharishvenk
@srivathsaharishvenk 2 года назад
@@steve-ardalis-smith I guess, regardless of the paradigm, the concept is still the same, it is better to avoid IO in the domain layer as much as possible, also IMHO c# is an hybrid language these days, not just OO
@MaxBeresnev
@MaxBeresnev 2 года назад
Thanks for cool presentation and template!
@nelsonthekinger
@nelsonthekinger 2 года назад
26:40 - I don't get the advantage of separating the specification from the repository, is it the possibility of reusing specifications over different repositories?
@nelsonthekinger
@nelsonthekinger 2 года назад
Oh and Great work with the presentation by the way
@Quasindro
@Quasindro 2 года назад
As the project grows bigger, you won't have a bloated and messy repository class. At least that's how I look at it.
@haroldpepete
@haroldpepete 2 года назад
Great talk, it would be nice if you put a QR code next to each link in the presentation, you don't see anytihing in the description of the video in youtube about links in the current presentation, sometimes links are so large
@Ardalis
@Ardalis Месяц назад
That's a great idea! I'll keep it in mind going forward.
@maksymkyian4920
@maksymkyian4920 2 года назад
It was great, keep doing what you doing guys =)
@evaldasraisutis3058
@evaldasraisutis3058 2 года назад
You say Core shouldn't have dependencies beyond shared kernel, but to implement specifications in the core project, you then have a dependency on a nugget package that provides specification abstraction, right? I realize it's a bit of give and take, but how would you navigate that decision in a new project?
@steve-ardalis-smith
@steve-ardalis-smith 2 года назад
This is a common question and sorry I didn't cover it better in the video. If you have pure code dependencies in Core or Shared Kernel, you can include them either directly within the project(s) or as NuGet references. Examples of pure code dependencies would be things like guard clauses, specifications, repository abstractions (not implementations, typically), fluent validations, etc. Basically, any dependency that simply runs in process and doesn't talk to external infrastructure concerns should be fair game.
@michaelvman
@michaelvman 2 года назад
@@steve-ardalis-smith I think Evaldas has a good point here as your specifications do have implicit knowledge of the underlying infrastructure. In your example project ProjectByIdWithItemsSpec uses the extension method Include from your Specification nuget. Use of this is obviously motivated by the knowledge EF is being used as the ORM. Of course IQueryable isn't a perfect abstraction and something like this isn't easy to reconcile with Clean Architecture, so definitely some give and take.
@steve-ardalis-smith
@steve-ardalis-smith 2 года назад
@@michaelvman It's true my Specification abstraction includes support for a .Include which can then be mapped to an EF/EF Core .Include, I'll grant that. But it's not specifically coupled to either of those frameworks (in that package - there are separate packages that are specific to EF/EF Core), and the use of .Include might be applied to other stores as well (imagine an OData backend or GraphQL building out an object graph, etc.). So, yes, I did purposefully choose to include features in my abstraction that easily mapped to my (current) implementation (because why make it hard?), but that doesn't mean I'm tied to the implementation.
@michaelvman
@michaelvman 2 года назад
@@steve-ardalis-smith I think you hit the nail on the head, why make it difficult and that's why there is some give and take. And I agree you're not coupling your specifications to a specific data store. All I'm suggesting is it's impossible for your business logic to be 100% ignorant of infrastructure concerns which is what Clean Architecture tries to aim for. Your Specification nuget allows you to use EF/OData/GraphQL features without directly coupling your business logic to those frameworks but you're still implicitly aware of how they expect to work and that's the compromise, albeit not a big one. I would be curious how elegantly specifications could be implemented when working with a data store that didn't use a LINQ interface. I'm guessing it wouldn't be possible and the heavy lifting would need to be done by a repository class. Anyway really like what you've done here and think I will try to use it as a starting point for my next project. Also very keen to give API Endpoints a spin, looks like a very promising approach.
@steve-ardalis-smith
@steve-ardalis-smith 2 года назад
@@michaelvman It is true that the LINQ-based Specification package I use (and maintain) works best with ORMs that support LINQ well. There have been efforts to apply it to Dapper and CosmosDB, for instance, that have met with limited success. The Specification *pattern* can still work with such back end stores and tools, but its implementation may need to change (for instance, if using Dapper, your specifications will likely contain raw SQL in them).
@MostafaAjy
@MostafaAjy Год назад
Can I use database first in clean arch???? Plz help me
@AleyCZ
@AleyCZ 2 года назад
I love this!
@zerosandones7547
@zerosandones7547 2 года назад
should we put our Extensions in the Domain/Core project as well?
@activoutdavid
@activoutdavid 2 года назад
I suggest that you put extensions classes in the same project and namespace as the class or interface they are extending, when possible.
@zerosandones7547
@zerosandones7547 2 года назад
@@activoutdavid even if they're just strings extensions?
@mohdilyas7962
@mohdilyas7962 2 года назад
Hi, Please explain how the architecture changes when the database first approach is being followed. I didn't find much information about it as I need to implement Clean architecture with the existing database model. Please explain.
@activoutdavid
@activoutdavid 2 года назад
I think that uou need to create "clean" domain entities in Core and have your Infrastructure convert between those and your existing database model.
@Ardalis
@Ardalis Месяц назад
@@activoutdavid Yes, exactly. The db first entities would need to live in an infrastructure project, and you would map to/from them, ideally. It may not be worth the effort, though...
@dotnetlearnyourself2298
@dotnetlearnyourself2298 2 года назад
Nice Video
@xustis
@xustis Год назад
Ty for video, i am not sure why if i search information about thisi find difefrent info on all sites. For example in this site we can see in the structure core, and uses cases but the most common structure is application and domain. I don't understand why microsoft don´t have a profesional template and maybe with examples and important thinks.
@muhammedshibin7786
@muhammedshibin7786 2 года назад
What if we have some , say DTOs that needs to be passed down for service implementation, where should we place them
@steve-ardalis-smith
@steve-ardalis-smith 2 года назад
"It depends". Sometimes it's really helpful to have DTOs in the Core project so everything can use them. However, most of the time these DTOs are only really used by some specific service, and aren't really a part of the "domain model". As such, they usually belong in the Web or Infrastructure project, or sometimes in a separate project (or nuget package) that these projects both reference. In that case it's usually a good idea to keep that project/package small and focused just on DTOs used for a specific purpose.
@muhammedshibin7786
@muhammedshibin7786 2 года назад
@@steve-ardalis-smith thanks
@pedrocosta8658
@pedrocosta8658 2 года назад
Just downloaded your template, a few questions: Why do we import the infrastructure project and not the Core project in the Web project ? Also how can we call the IToDoItemSearchService interface from Web if it is defined in Core and we don't import that project in Web ? Sorry for the confusing phrasing 😅
@pedrocosta8658
@pedrocosta8658 2 года назад
i think i understand now. We do import Infrastructure because we need to add the implementations to the dependency injection container and that would be impossible without importing the project in which the implementations are. Also we import Core, it's just not appearing in the dependencies tab in my project, but we're making "using ..... core" in some pages so yeah
@hussainhussaini2267
@hussainhussaini2267 Год назад
I don't understand something. I pulled the sample solution and see the Web project has no reference to the Core project, while it has a reference to the Infrastructure project. This not what stated in the video. In the video it's said that both Infrastructure and Web projects should talk through Core project indirectly
@lakshparab7066
@lakshparab7066 2 года назад
I think realistically it not possible to simply replace the DB without changing Domain Service logic. With proposed clean architecture the EntityFramework is now abstracted but ApplicationCore is now depend on `Ardalis.Specification` which is just a wrapper around EF and exposes EF's extension methods via Specification. For example Include(), AsNoTracking() etc which may not be suitable for different database. So if you change DB, you most probably have to change specifications and that means domain service as well.
@activoutdavid
@activoutdavid 2 года назад
As Steve mentioned, Ardalis.Specification is one of his own projects, and most Clean Architecture implementations probably don't have it unless they use his Clean Architecture template... :)
@c-sharptricks9899
@c-sharptricks9899 2 года назад
ls this architecture good for microservices? please respond anyone who have used it or can provide a best link for that purpose. Thanking you in advance..
@Siuari1
@Siuari1 2 года назад
So, if i have to implement a TokenService that has external dependencies like microsoft jwt packages, for exemple. My question is: Will it go on infrastructure?
@activoutdavid
@activoutdavid 2 года назад
If the tokens is used in Infrastructure for calling an API then the TokenService also belongs in Infrastructure. Tokens are probably not part of the Domain/Core.
@clashclan4739
@clashclan4739 2 года назад
For complex problem give simple solution. I have seen in the name of ddd/onion/hexagonal architecture ppls tends to makes project complex to work and modify
@cburys
@cburys Год назад
regarding the diagram at 6:44 and how everyone says dependencies should flow towards the core project, doesn't the core project have to import the infrastructure project? Are y'all saying it's not dependent on it simply because the interfaces for the services and models are defined in in the core project?
@yuvarajvelmuruganmudaliyar
@yuvarajvelmuruganmudaliyar Год назад
Domain layer is the CORE and it doesn't depends on anything else. The core contains domain/business models and domain/business logic.
@Ardalis
@Ardalis Месяц назад
@@yuvarajvelmuruganmudaliyar Correct. It uses the Dependency Inversion Principle such that interfaces are defined in Core/Domain project but implementations are in Infrastructure project.
@ADSNGreenLife
@ADSNGreenLife 2 года назад
What about If I want to create Microservice and inject it where should I do that? Can we have Angular template with clean architecture ?
@activoutdavid
@activoutdavid 2 года назад
You can implement a microservice according to Clean Architecture. If you are calling other microservices you do that from the Infrastructure project.
@ADSNGreenLife
@ADSNGreenLife 2 года назад
@@activoutdavid thanks David for clearification.
@ADSNGreenLife
@ADSNGreenLife 2 года назад
@@activoutdavid How about If we want to host on azure. Few are Azure Function and Rest api then are we going to publish separate in projects and host it? is it so ?
@primelimitt
@primelimitt Год назад
why is this not called Domain Driven Design with asp.NET Core 6? I m new to all these and it's really hard to understand what's clean architecture and what's DDD.
@tarasstrypko8160
@tarasstrypko8160 2 года назад
1. Why use custom exceptions if we can propagate Error result from operations? The problem I see with exception, that flow is a bit implicit, and sometimes it's not very easy to properly handle such exceptions. As in different places same exception could mean different things from application perspective. As an example: throw custom exception in entity constructor, have a generic handler, which catches it and maps to 400 response, which sounds not so bad, when user tries to create that entity. But, what if that exception is going to be thrown when entity is being de-serialized from cosmos, for some other operation on it (corrupted data in db)? User will get 400, when 500 should be returned. 2. Not sure I understand, why do we need Repository Interfaces in domain layer? Why can't we have them in Infrastructure layer? We're anyway going to have some kind of application layer (in your case UI project), which will glue Domain and Infra layers together. Don't we? 3. Is it real the case, that Domain layer is completely independent from DB structure? As from my experience, it was pretty hard to achieve this due to some ORM limitations or similar. Might be, I was doing something wrong. 4. You mentioned that Core project is good for Validators like fluent validation. Do you use fluent validation in your domain model? As if it's about request DTOs, then it seems more like application layer concern, isn't it? Similar question for specifications - should domain layer care about queries? Why not put them into application layer close to appropriate use-cases?
@activoutdavid
@activoutdavid 2 года назад
1. Exceptions should be for exceptional cases. If you let a Cosmos exception propagate from Infrastructure, then you can't catch it in Web or Core because they don't know what Cosmos is. But if you wrap it in a "CorruptDataException" then you can catch it in Web and return a 500 :) 2. The Web layer should not know anyhing about the Infrastructure layer. It only depends on it to setup dependency injection. So any interfaces that are used by both Web and Infrastructure must be in the Core project. 3. Yes, if you work with clean architecture you create pure domain entities and only the Infrastructure project knows what ORM you are using and converts to and from the domain entities. But you could decide to let it leak a bit into Core in your application :) 4. If you think about it, validation is actually business logic.
@acp3012
@acp3012 2 года назад
I have a question, I am developing 3 microservices which is part of an application. There is a situation we use common functionalities acroess each project/layers. For example Exception handling and Entities can be used in multiple microservices. My question is where can we keep this common libraries in Clean architecture?. Do we need to have another layer that hold only common functionalities?. if we are going to have separate library then CORE, API, INFRA all layer may depend on the common library.
@activoutdavid
@activoutdavid 2 года назад
Try to reduce dependencies if you can so that each microservice can be deployed as independently as possible. I think that if you have the same entities in multiple services you should consider merging the services or slicing them differently so that they don't need to share entities. For example do not share a single database between multiple microservices. Or maybe you can actually just copy shared classes between projects.
@임진호-x4x
@임진호-x4x 2 года назад
Thanks
@diligencehumility6971
@diligencehumility6971 2 года назад
Is it doable to use this pattern with Azure Functions?
@mart0347
@mart0347 2 года назад
Yes. If you are using DI with your function then you may use CQRS.
@nateg247
@nateg247 2 года назад
I was thinking the same and somehow not completely convinced. Some concepts can be applied though
@diligencehumility6971
@diligencehumility6971 2 года назад
@@nateg247 I am not sure if Functions should be seen as microservices, and thus your functions have to communicate with each other. Which seems silly. Instead of having the data access in the stomach of your application. Was thinking using MediatR, and simply inject MediatR into the Functions projects. Is this doable?
@mart0347
@mart0347 2 года назад
@@diligencehumility6971 Yes!
@diligencehumility6971
@diligencehumility6971 2 года назад
@@mart0347 But doing it this way, my Functions project will have a reference to my Application project, which will be a DLL with all my functions. A single Azure Function is meant to represent one controller in traditional api right? So I might have a Product Functions project, which have get/post/delete/put methods for Products right?
@Tetsuro-s8p
@Tetsuro-s8p 2 года назад
Thanks for such interesting talk! But how in this architecture we should call business logic from webapi?
@Ardalis
@Ardalis Месяц назад
Ideally business logic lives in Core/Domain project. Web API gets to it via Application Services or by sending messages (Commands, Queries) via MediatR which are handled in an Application or UseCases project. The application services/handlers use the domain model types along with persistence abstractions to do the work and persist any state changes.
@rahulsen002
@rahulsen002 2 года назад
Under what situation will I ever use SQL lite in an environment, SQL server in another and cosmosdb in prod
@RajaKajiev
@RajaKajiev 2 года назад
1 - local dev testing, 2 - prod on premise, 3 - cloud-hosted deployment ?
@turn1210
@turn1210 2 года назад
Yeah, that sounds like an accent waiting to happen
@kostasgkoutis8534
@kostasgkoutis8534 2 года назад
Haha, love the T-shirt
@duongkytruong
@duongkytruong 2 года назад
tks
@pablocom
@pablocom 2 года назад
lovely tshirt xD
@alpsavasdev
@alpsavasdev Год назад
what does ardalis mean?
@jaanustilk2769
@jaanustilk2769 2 года назад
So Web actually depends on Infrastructure not on Core. I dont see this as a problem but I dont understand why this is not clearly stated in the video.
@pedrocosta8658
@pedrocosta8658 2 года назад
but do you understand why ? I mean in the Web project we wanna call business methods, not infrastructure right ?
@activoutdavid
@activoutdavid 2 года назад
Web depends on Infrastructure because it needs to setup dependency injections for Infrastructure. But it may not call directly into Infrastructure :)
@gibran800
@gibran800 2 года назад
Awesome!
@nonamezz20
@nonamezz20 2 года назад
Where would you place a hosted service ?
@activoutdavid
@activoutdavid 2 года назад
The IHostedService or the BackgroundService are implemented either in the Web or the Infrastructure project depending on the circumstances, but that implementation can then use domain logic in Core.
@sweeperq
@sweeperq 2 года назад
What do you do when you have items in your domain that depend on Identity Users? For instance, an e-Shop may have an Order table with a reference to the User Id that placed the order. If I want to view all of the orders for a single user that works just fine *var orders = await context.Orders.Where(x => x.UserId = 10).ToListAsync()*. However, if I want to show a list of orders with associated user details (name, email, etc), all of a sudden I have 1 + N queries because the Identity User is in the Infrastructure class and our other entities cannot reference it. For instance, we cannot do _var orders = await context.Orders.Include(x => x.User).Where(x => x.User.LastName = "Anderson")_ because introducing User would create a circular dependency between the Domain and Infrastructure layers.
@hakoningvaldsen8046
@hakoningvaldsen8046 2 года назад
You can not in any way depend on Identity User in Infrastructure from Core. You would need to have an Interface in Core representing the Identity and let Infrastructure implementation map and inject into Core. You could then replace your Identity system completely, as long as the new system can map to and honor the Interface of Identity in Core. This is the whole point, and where the cleaness comes from.
@Ardalis
@Ardalis Месяц назад
For raw queries I would typically avoid trying to use the domain model (which is built for mutations/updates) and instead just execute a database query directly. In many cases the identity information will be on a separate database or somewhere else entirely (for instance, Okta, Azure Entra, etc) so it may make sense to have a local *materialized view* of the user information you wish to display, which is periodically updated from the actual source.
@sergeiburtsev5712
@sergeiburtsev5712 2 года назад
The topic's architecture as I see it: let's have a big monolith in the center and surround it with some helper projects that will help it work somehow.
@steve-ardalis-smith
@steve-ardalis-smith 2 года назад
If you think a domain model with no dependencies on UI or data or other infrastructure is "a big monolith" then I could see how you might arrive at this conclusion. However, a domain model is, in fact, just a class library, not a monolith.
@prendas52
@prendas52 2 года назад
that template works in VS code?
@Ardalis
@Ardalis Месяц назад
Of course. It's just a solution file and projects...
@M4tt1mus
@M4tt1mus 2 года назад
The examples of going with Clean in the beginning are just examples of general bad architecture or don't give you much. For example, Business Logic in the DB is frowned upon by all modern architecture approaches, no?
@HeitorGiacomini
@HeitorGiacomini 2 года назад
DotNetCoreWeb have a reference to Infrastructure. Why?
@activoutdavid
@activoutdavid 2 года назад
To setup dependency injection
@Ardalis
@Ardalis Месяц назад
@@activoutdavid Yes, just for convenience. You can move composition root to another project if it really bugs you or you need to keep that separation "pure".
@PhantomAxxaxxin
@PhantomAxxaxxin 2 года назад
Prefer Vertical Slice Architecture by Jimmy B.
@angmathew4377
@angmathew4377 2 года назад
Hi Everyone, @here can I have some thing similar for Node.js and express?
@burakgozen8932
@burakgozen8932 2 года назад
Can anyone help me with migrations in this example?
@nothingbuthardwork8336
@nothingbuthardwork8336 2 года назад
Did someone know what kind of tool he use for zooming and drawing the red arrows?
@bobmcbob4399
@bobmcbob4399 2 года назад
ZoomIt I believe.
@jamesmclachlan2234
@jamesmclachlan2234 2 года назад
Nodding yes for 29 minutes and 57 seconds :)
@gijduvon6379
@gijduvon6379 2 года назад
Sorry, but this template is really mess! Repository calls in controller, specifications, ifelses. Nothing clean found....
@ram62836
@ram62836 2 года назад
Why API contracts are not within core?
@kaasbaas9532
@kaasbaas9532 2 года назад
application logic != domain logic
@mishashins
@mishashins 2 года назад
I used ur architecture its hard but its funny
@pauloperovic5683
@pauloperovic5683 2 года назад
not using miscrosoft edge? ccc :P
@clashclan4739
@clashclan4739 2 года назад
I totally disagree with aggregate root concept. There can be multiple scenarios i just have to crud on depended entity like order details without a need of aggregate root. Then why forcing it in the name of ddd
@Ardalis
@Ardalis Месяц назад
Like all patterns, use it when it's useful.
@jayakumar2927
@jayakumar2927 Год назад
your github roject shows always unloaded all projeccts
@dmitrynenazhenko209
@dmitrynenazhenko209 2 года назад
I use Clean architecture for my project, it is a little bit different though and even less depend on each layer. However using Value Objects is a real pain in the ass. First of all if you create your domain model and use it as main entity you can only guarantee that your value objects will be validated during Insert/Update requests from front-end. If you are trying to build your domain entity from external dependency or even from database request you may not guarantee that your Value Object will match the data that you got and it will break with validation. If external service that you are relying on return you something that you are not expecting, your application will fail on the stage of building that Value Objects
@nyonor7314
@nyonor7314 2 года назад
Builder pattern в помощь?
@activoutdavid
@activoutdavid 2 года назад
I think that in this case you should have a separate entity (call it DTO or API Model if you want) in Infrastructure without the value objects, and then you write code to map from the infrastructure entity to the domain entity and handle validation errors.
@Petoj87
@Petoj87 2 года назад
While I loved this, it was a bit rushed
@OeHomestead
@OeHomestead 2 года назад
Nice, but wow, that's really, IMHO, making things way too complex for normal projects.
@vasilymeleshko
@vasilymeleshko 2 года назад
Если честно, ничего нового, для солид решений это называлось платформенными сборками разделенными по зонам и уровням ответственности.
@botyironcastle
@botyironcastle Год назад
this is not clean arch this is technical layering
@rahulmathew8713
@rahulmathew8713 2 года назад
Your database and related should be a separate solution and a microservice else its not reusable . Now only your web app can call it. If I want a mobile app and thats wants to call the same dal then. Should I reinvent wheel again, wasting companies time for redoing whatever we did to build those db related things.
@DigitalNomadOnFIRE
@DigitalNomadOnFIRE 2 года назад
Fall into the pit of success LMFAO...
@halivudestevez2
@halivudestevez2 2 года назад
is it clean? not for me :D
@yesubabu2880
@yesubabu2880 2 года назад
Great explanation..thanks for confusing me..did not explain well..But u r a good developer not a good presenter
@Philinnor
@Philinnor 2 года назад
It's hard to trust someone not using dark theme.
@Ardalis
@Ardalis Месяц назад
I normally do but not for presentations since light theme is often easier to see in different lighting conditions.
@andrewsoldan6050
@andrewsoldan6050 2 года назад
Overthought, overused, unnecessary complex, ugly - I hate today's IT after 20 years in the business. LOL
@ВиталийБулдаков-ш4э
So bad I can't like it twice
@澳贼
@澳贼 2 года назад
first.
Далее
Clean Architecture with ASP.NET Core 7 | .NET Conf 2022
27:58
Forget Controllers and Minimal APIs in .NET!
14:07
Просмотров 72 тыс.
Clean ASP.NET Core API using MediatR and CQRS | Setup
22:39
ASP.NET Core Crash Course - C# App in One Hour
1:00:44
Просмотров 1,6 млн
Ryan Dahl introduces JSR at DevWorld 2024
29:13
Просмотров 111 тыс.
You are doing .NET logging wrong. Let's fix it
25:29
Просмотров 173 тыс.
Should I Focus on Blazor or ASP.NET Core?
12:39
Просмотров 79 тыс.
Understand Clean Architecture in 7 Minutes
7:02
Просмотров 110 тыс.