Clean Architecture with ASP.NET Core 6

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 พ.ย. 2024
  • Clean Architecture (aka Onion, Hexagonal, Ports-and-Adapters) organizes your code in a way that limits its dependencies on infrastructure concerns. Learn how to apply it to your ASP.NET Core apps!
    aka.ms/dotNETC... 👨‍💻 Slides & code: aka.ms/dotnetc...
    🎉 .NET 6 Release Blog: devblogs.micro...
    ⬇ Download .NET 6: aka.ms/dotNETC...
    🙋‍♀️🙋‍♂️ Get your questions answered on the Microsoft Q&A for .NET: aka.ms/dotnet-qa
    💭 Join the .NET Tech Community Forums: aka.ms/dotnet/...
    🏫 Learn C#, F#, and .NET with free self-guided learning from Microsoft Learn: aka.ms/learndo...
    #dotnet6 #dotnetconf #dotnet

ความคิดเห็น • 210

  • @Greenthum6
    @Greenthum6 3 ปีที่แล้ว +141

    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 3 ปีที่แล้ว +13

      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 3 ปีที่แล้ว +32

      @@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 3 ปีที่แล้ว +18

      @@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 3 ปีที่แล้ว +8

      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: th-cam.com/video/dK4Yb6-LxAk/w-d-xo.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 3 ปีที่แล้ว +43

      @@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.

  • @mattferderer469
    @mattferderer469 3 ปีที่แล้ว +21

    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 3 ปีที่แล้ว +7

    | 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

  • @S3Kglitches
    @S3Kglitches 3 ปีที่แล้ว +1

    this video is extremely useful and people have to realize that it is a more robust extension of three-tier architecture

  • @cethrivias
    @cethrivias 3 ปีที่แล้ว +3

    It finally clicked for me why it is called *Domain-Driven* Architecture

  • @rbp365
    @rbp365 3 ปีที่แล้ว +3

    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

  • @albxdotcom
    @albxdotcom 2 ปีที่แล้ว +1

    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 3 หลายเดือนก่อน

      Exactly what it's designed for!

  • @RoggemansG
    @RoggemansG 3 ปีที่แล้ว +1

    Thank you Steve for all these precious gifts you make for us!

  • @CodewithFemi
    @CodewithFemi 3 ปีที่แล้ว +3

    Thanks Steve for taking us through this. I love clean architecture!

  • @Gonkers44
    @Gonkers44 3 ปีที่แล้ว +5

    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 3 ปีที่แล้ว

      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.

  • @vincidixit
    @vincidixit 3 ปีที่แล้ว +9

    Very helpful. Well explained with examples and demo. This will definitely make things easy.

  • @MostafaAjy
    @MostafaAjy 2 ปีที่แล้ว

    Can I use database first in clean arch???? Plz help me

  • @caglarad2544
    @caglarad2544 2 ปีที่แล้ว +1

    Thanks Steve for sharing your valuable information with us.

  • @Erril_Ferndal
    @Erril_Ferndal 2 ปีที่แล้ว +1

    Thanks Steve! I really like Clean Architecture

  • @browaruspierogus2182
    @browaruspierogus2182 2 ปีที่แล้ว +4

    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 ปีที่แล้ว +3

    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 3 หลายเดือนก่อน

      "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.

  • @BabakSekandari-q1c
    @BabakSekandari-q1c ปีที่แล้ว +1

    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.

  • @PeriMCS
    @PeriMCS 3 ปีที่แล้ว +1

    Uncle bob taught me this Clean Architecture about 20 years ago. I thought I will see something new here.

  • @nicolasundiano8406
    @nicolasundiano8406 2 ปีที่แล้ว +1

    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

    •  2 ปีที่แล้ว

      Constants to the Core project. PaginationHelper to the project where your UI lives.

  • @dvanrooyen1434
    @dvanrooyen1434 3 ปีที่แล้ว +1

    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.

  • @Sad-Lemon
    @Sad-Lemon 2 ปีที่แล้ว +1

    I absolutely love the shirt :D
    Just started watching :)

  • @yasharaliabbasi5653
    @yasharaliabbasi5653 2 ปีที่แล้ว +1

    Thank you for your useful topic, How should we add authentication and authorization?

    • @activoutdavid
      @activoutdavid 2 ปีที่แล้ว +1

      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.

  • @omidkarami4312
    @omidkarami4312 2 ปีที่แล้ว +1

    Hi Steve, thanks so much for the amazing video, what is the best way to contact you for consulting?

  • @belmo_
    @belmo_ 3 ปีที่แล้ว +1

    I didn't know that I needed this video.

  • @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?

  • @alpsavasdev
    @alpsavasdev ปีที่แล้ว

    what does ardalis mean?

  • @srivathsaharishvenk
    @srivathsaharishvenk 3 ปีที่แล้ว +3

    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 3 ปีที่แล้ว

      Yes you can certainly achieve similar things in functional languages. This is "mostly OO based" because C# is an OO language.

    • @srivathsaharishvenk
      @srivathsaharishvenk 3 ปีที่แล้ว

      @@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

  • @ebrimasidibeh7587
    @ebrimasidibeh7587 2 ปีที่แล้ว +2

    Nice one 👍. I love DDD and there is always different ideas among developers about its architecture but having standard template is awesome 👌

  • @nelsonthekinger
    @nelsonthekinger 3 ปีที่แล้ว +1

    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 3 ปีที่แล้ว

      Oh and Great work with the presentation by the way

    • @Quasindro
      @Quasindro 3 ปีที่แล้ว

      As the project grows bigger, you won't have a bloated and messy repository class. At least that's how I look at it.

  • @muhammedshibin7786
    @muhammedshibin7786 3 ปีที่แล้ว +1

    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 3 ปีที่แล้ว +1

      "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 3 ปีที่แล้ว

      @@steve-ardalis-smith thanks

  • @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..

  • @mohdilyas7962
    @mohdilyas7962 2 ปีที่แล้ว +1

    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 3 หลายเดือนก่อน

      @@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...

  • @rodelias9378
    @rodelias9378 2 ปีที่แล้ว +1

    Really awesome talk! Thanks a lot!!

  • @jegtugado3743
    @jegtugado3743 3 ปีที่แล้ว +1

    Awesome presentation. This reinforced my understanding of implementing DDD and Clean Architecture. Thank you, cool template.

  • @hussainhussaini2267
    @hussainhussaini2267 2 ปีที่แล้ว

    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

  • @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.

  • @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.

  • @UndersVzLOM
    @UndersVzLOM 2 ปีที่แล้ว

    Very helpful. Where can i read more on those repository, it's base class and specifications? Thanks

  • @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.

  • @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 2 ปีที่แล้ว

    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 2 ปีที่แล้ว +1

      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 3 หลายเดือนก่อน

      @@yuvarajvelmuruganmudaliyar Correct. It uses the Dependency Inversion Principle such that interfaces are defined in Core/Domain project but implementations are in Infrastructure project.

  • @julietchoy
    @julietchoy 3 ปีที่แล้ว +2

    Thank you so much for putting this up!!

  • @ahadporkar7355
    @ahadporkar7355 3 ปีที่แล้ว +1

    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.

  • @shatiswaranvigian9349
    @shatiswaranvigian9349 2 ปีที่แล้ว +1

    Very helpful, thank you.

  • @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 3 ปีที่แล้ว +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

      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.

  • @nonamezz20
    @nonamezz20 2 ปีที่แล้ว

    Where would you place a hosted service ?

    • @activoutdavid
      @activoutdavid 2 ปีที่แล้ว +1

      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.

  • @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... :)

  • @burakgozen8932
    @burakgozen8932 2 ปีที่แล้ว

    Can anyone help me with migrations in this example?

  • @evaldasraisutis3058
    @evaldasraisutis3058 3 ปีที่แล้ว +1

    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 3 ปีที่แล้ว +1

      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 3 ปีที่แล้ว +1

      @@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 3 ปีที่แล้ว

      @@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 3 ปีที่แล้ว +1

      @@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 3 ปีที่แล้ว

      @@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).

  • @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 ปีที่แล้ว +1

      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 ?

  • @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 3 หลายเดือนก่อน

      That's a great idea! I'll keep it in mind going forward.

  • @francogiulianopertile279
    @francogiulianopertile279 2 ปีที่แล้ว

    Aweesome presentation

  • @pedrocosta8658
    @pedrocosta8658 3 ปีที่แล้ว

    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 3 ปีที่แล้ว +1

      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

  • @baolam4180
    @baolam4180 2 ปีที่แล้ว +1

    Thanks. Great explanation at right time for me 😍

  • @waymanharris1284
    @waymanharris1284 3 ปีที่แล้ว +1

    #Support #Awesome This is the most helpful youtube video I watched all year.

  • @diligencehumility6971
    @diligencehumility6971 3 ปีที่แล้ว +2

    Is it doable to use this pattern with Azure Functions?

    • @mart0347
      @mart0347 3 ปีที่แล้ว +1

      Yes. If you are using DI with your function then you may use CQRS.

    • @nateg247
      @nateg247 3 ปีที่แล้ว

      I was thinking the same and somehow not completely convinced. Some concepts can be applied though

    • @diligencehumility6971
      @diligencehumility6971 3 ปีที่แล้ว +1

      @@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 3 ปีที่แล้ว +1

      @@diligencehumility6971 Yes!

    • @diligencehumility6971
      @diligencehumility6971 3 ปีที่แล้ว

      @@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?

  • @konoko-o3o
    @konoko-o3o 2 ปีที่แล้ว +1

    Awesome content, thank you!

  • @rahulsen002
    @rahulsen002 3 ปีที่แล้ว

    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

  • @125Jackal
    @125Jackal 3 ปีที่แล้ว

    Steve! How u doin? Just wanted to say that I love your courses in Pluralsight.

  • @prendas52
    @prendas52 2 ปีที่แล้ว

    that template works in VS code?

    • @Ardalis
      @Ardalis 3 หลายเดือนก่อน

      Of course. It's just a solution file and projects...

  • @wilfredogutierrez1640
    @wilfredogutierrez1640 3 ปีที่แล้ว +1

    Thank you for sharing, very useful

  • @angmathew4377
    @angmathew4377 2 ปีที่แล้ว

    Hi Everyone, @here can I have some thing similar for Node.js and express?

  • @jaanustilk2769
    @jaanustilk2769 3 ปีที่แล้ว

    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 3 ปีที่แล้ว

      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 :)

  • @MaxBeresnev
    @MaxBeresnev 3 ปีที่แล้ว

    Thanks for cool presentation and template!

  • @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 3 หลายเดือนก่อน

      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.

  • @nothingbuthardwork8336
    @nothingbuthardwork8336 3 ปีที่แล้ว

    Did someone know what kind of tool he use for zooming and drawing the red arrows?

  • @dotnetlearnyourself2298
    @dotnetlearnyourself2298 2 ปีที่แล้ว

    Nice Video

  • @ram62836
    @ram62836 3 ปีที่แล้ว

    Why API contracts are not within core?

    • @kaasbaas9532
      @kaasbaas9532 3 ปีที่แล้ว +1

      application logic != domain logic

  • @jayakumar2927
    @jayakumar2927 2 ปีที่แล้ว

    your github roject shows always unloaded all projeccts

  • @maksymkyian4920
    @maksymkyian4920 3 ปีที่แล้ว

    It was great, keep doing what you doing guys =)

  • @HeitorGiacomini
    @HeitorGiacomini 2 ปีที่แล้ว

    DotNetCoreWeb have a reference to Infrastructure. Why?

    • @activoutdavid
      @activoutdavid 2 ปีที่แล้ว

      To setup dependency injection

    • @Ardalis
      @Ardalis 3 หลายเดือนก่อน

      @@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".

  • @M4tt1mus
    @M4tt1mus 3 ปีที่แล้ว

    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?

  • @pauloperovic5683
    @pauloperovic5683 2 ปีที่แล้ว

    not using miscrosoft edge? ccc :P

  • @gijduvon6379
    @gijduvon6379 2 ปีที่แล้ว

    Sorry, but this template is really mess! Repository calls in controller, specifications, ifelses. Nothing clean found....

  • @PhantomAxxaxxin
    @PhantomAxxaxxin 2 ปีที่แล้ว

    Prefer Vertical Slice Architecture by Jimmy B.

  • @임진호-x4x
    @임진호-x4x 2 ปีที่แล้ว

    Thanks

  • @Tetsuro-s8p
    @Tetsuro-s8p 2 ปีที่แล้ว

    Thanks for such interesting talk! But how in this architecture we should call business logic from webapi?

    • @Ardalis
      @Ardalis 3 หลายเดือนก่อน

      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.

  • @sergeiburtsev5712
    @sergeiburtsev5712 3 ปีที่แล้ว +1

    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 3 ปีที่แล้ว

      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.

  • @AleyCZ
    @AleyCZ 3 ปีที่แล้ว

    I love this!

  • @jamesmclachlan2234
    @jamesmclachlan2234 3 ปีที่แล้ว +2

    Nodding yes for 29 minutes and 57 seconds :)

  • @pablocom
    @pablocom 3 ปีที่แล้ว

    lovely tshirt xD

  • @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 3 หลายเดือนก่อน

      Like all patterns, use it when it's useful.

  • @Petoj87
    @Petoj87 3 ปีที่แล้ว +2

    While I loved this, it was a bit rushed

  • @dmitrynenazhenko209
    @dmitrynenazhenko209 3 ปีที่แล้ว

    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.

  • @duongkytruong
    @duongkytruong 2 ปีที่แล้ว

    tks

  • @mishashins
    @mishashins 3 ปีที่แล้ว

    I used ur architecture its hard but its funny

  • @kostasgkoutis8534
    @kostasgkoutis8534 3 ปีที่แล้ว +1

    Haha, love the T-shirt

  • @gibran800
    @gibran800 3 ปีที่แล้ว +1

    Awesome!

  • @OeHomestead
    @OeHomestead 3 ปีที่แล้ว

    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.

  • @halivudestevez2
    @halivudestevez2 2 ปีที่แล้ว

    is it clean? not for me :D

  • @Philinnor
    @Philinnor 2 ปีที่แล้ว +1

    It's hard to trust someone not using dark theme.

    • @Ardalis
      @Ardalis 3 หลายเดือนก่อน

      I normally do but not for presentations since light theme is often easier to see in different lighting conditions.

  • @yesubabu2880
    @yesubabu2880 2 ปีที่แล้ว

    Great explanation..thanks for confusing me..did not explain well..But u r a good developer not a good presenter

  • @DigitalNomadOnFIRE
    @DigitalNomadOnFIRE 2 ปีที่แล้ว +1

    Fall into the pit of success LMFAO...

  • @ShadowAimai
    @ShadowAimai 3 ปีที่แล้ว +1

    So this is useful for those poor souls still using ASP.NET?

  • @ВиталийБулдаков-ш4э
    @ВиталийБулдаков-ш4э ปีที่แล้ว

    So bad I can't like it twice

  • @andrewsoldan6050
    @andrewsoldan6050 3 ปีที่แล้ว

    Overthought, overused, unnecessary complex, ugly - I hate today's IT after 20 years in the business. LOL