clean architecture
play

Clean Architecture Jason Taylor Join the Conversation #GOTOCph - PowerPoint PPT Presentation

Clean Architecture Jason Taylor Join the Conversation #GOTOCph @JasonGtAu Join the Conversation #GOTOCph @JasonGtAu Jason Taylor SSW Solution Architect Visiting from Australia .NET Developer Since 2002 Keep It Simple, Stupid! jasongtau


  1. Clean Architecture Jason Taylor Join the Conversation #GOTOCph @JasonGtAu

  2. Join the Conversation #GOTOCph @JasonGtAu

  3. Jason Taylor SSW Solution Architect Visiting from Australia .NET Developer Since 2002 Keep It Simple, Stupid! jasongtau github.com/jasongt codingflow.net youtube.com/jasongt Join the Conversation #DotNetCoreSuperpowers @SSW_TV

  4. Clean Architecture Domain Layer Application Layer Agenda Infrastructure Layer Presentation Layer Next Steps

  5. Clean Architecture Presenta sentation tion Applica ication tion Independent of frameworks Testable Domai main Independent of UI Independent of database Independent anything external Infrastr struct cture Join the Conversation #GOTOCph @JasonGtAu

  6. Northwind Traders Sample Clean Architecture ASP.NET Core 3.0 Entity Framework Core 3.0 ASP.NET Core Identity 3.0 Repo bit.ly/northwind-traders Join the Conversation #GOTOCph @JasonGtAu

  7. Clean Architecture Template .NET Core Template Package ASP.NET Core 3.0 Entity Framework Core 3.0 ASP.NET Core Identity 3.0 Repo bit.ly/ca-sln Join the Conversation #GOTOCph @JasonGtAu

  8. Key Points Domain contains enterprise-wide logic and types Application contains business-logic and types Infrastructure contains all external concerns Presentation and Infrastructure depend only on Application Infrastructure and Presentation components can be replaced with minimal effort Join the Conversation #GOTOCph @JasonGtAu

  9. Clean Architecture Domain Layer Application Layer Agenda Infrastructure Layer Presentation Layer Next Steps

  10. Overview Presenta sentation tion Applica ication tion Entities Value Objects Domai main Enumerations Logic Exceptions Infrastr struct cture Join the Conversation #GOTOCph @JasonGtAu

  11. Demo Reviewing the Domain layer Join the Conversation #GOTOCph @JasonGtAu

  12. Key Points Avoid using data annotations Use value objects where appropriate Create custom domain exceptions Initialise all collections & use private setters Automatically track changes Join the Conversation #GOTOCph @JasonGtAu

  13. Clean Architecture Domain Layer Application Layer Agenda Infrastructure Layer Presentation Layer Next Steps

  14. Overview Presenta sentation tion Applica ication tion Interfaces Models Domai main Logic Commands / Queries Validators Exceptions Infrastr struct cture Join the Conversation #GOTOCph @JasonGtAu

  15. CQRS Command Query Responsibility Segregation Separate reads (queries) from writes (commands) Can maximise performance, scalability, and simplicity Easy to add new features, just add a new query or command Easy to maintain, changes only affect one command or query Join the Conversation #GOTOCph @JasonGtAu

  16. CQRS + MediatR = ♥ Define commands and queries as requests Application layer is just a series of request / response objects Ability to attach additional behaviour before and / or after each request, e.g. logging, validation, caching, authorisation and so on Join the Conversation #GOTOCph @JasonGtAu

  17. Demo Reviewing the Application layer Join the Conversation #GOTOCph @JasonGtAu

  18. Key Points Using CQRS + MediatR simplifies your overall design MediatR simplifies cross cutting concerns Fluent Validation is useful for all validation scenarios AutoMapper simplifies mapping and projections Independent of infrastructure concerns Join the Conversation #GOTOCph @JasonGtAu

  19. Clean Architecture Domain Layer Application Layer Agenda Infrastructure Layer Presentation Layer Next Steps

  20. Overview Presenta sentation tion Applica ication tion Persistence Identity Domai main File System System Clock API Clients Infrastr struct cture Join the Conversation #GOTOCph @JasonGtAu

  21. Unit of Work and Repository Patterns Should we implement these patterns? It isn’t always the best choice, because: EF Core insulates your code from database changes DbContext acts as a unit of work DbSet acts as a repository EF Core has features for unit testing without repositories Join the Conversation #GOTOCph @JasonGtAu

  22. What do the experts think? I’m over Repositories, and No, you don’t need a repository. No, the repository/unit-of-work definitely over abstracting your But there are many benefits pattern isn’t useful with EF data layer. and you should consider it! Core. Join the Conversation #GOTOCph @JasonGtAu

  23. Demo Reviewing the Infrastructure layer Join the Conversation #GOTOCph @JasonGtAu

  24. Key Points Independent of the database Use Fluent API configuration over data annotations Prefer conventions over configuration Automatically apply all entity type configurations No layers depend on Infrastructure layer, e.g. Presentation layer Join the Conversation #GOTOCph @JasonGtAu

  25. Clean Architecture Domain Layer Application Layer Agenda Infrastructure Layer Presentation Layer Next Steps

  26. Overview Presenta sentation tion Applica ication tion SP SPA A – An Angular, ular, React act, , Vue ue Web AP API Domai main Razor Pages MVC Web Forms Infrastr struct cture Join the Conversation #GOTOCph @JasonGtAu

  27. Demo Reviewing the Presentation layer Join the Conversation #GOTOCph @JasonGtAu

  28. Key Points Controllers should not contain any application logic Create and consume well defined view models Open API bridges the gap between the front end and back end NSwag automates generation of Open API specification and clients Join the Conversation #GOTOCph @JasonGtAu

  29. Clean Architecture Domain Layer Application Layer Agenda Infrastructure Layer Presentation Layer Next Steps

  30. Using the Solution Template C:\Code\CaTodo>dotnet new -i Clean.Architecture.Solution.Template C:\Code\CaTodo>dotnet new ca-sln The template "Clean Architecture Solution" was created successfully. C:\Code\CaTodo> Join the Conversation #GOTOCph @JasonGtAu

  31. Join the Conversation #GOTOCph @JasonGtAu

  32. Join the Conversation #GOTOCph @JasonGtAu

  33. Thank you! @jasongtau bit.ly/ca-sln bit.ly/northwind-traders info@ssw.com.au www.ssw.com.au Sydney | Melbourne | Brisbane

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend