Presentation is loading. Please wait.

Presentation is loading. Please wait.

Vertical Feature Slices Not Layers

Similar presentations


Presentation on theme: "Vertical Feature Slices Not Layers"— Presentation transcript:

1 Vertical Feature Slices Not Layers
Derek Comartin @codeopinion codeopinion.com

2 Context

3

4 Tech Clients & Server

5 Authorization

6 Authorization Data Access

7 Authorization Data Access Validation

8 Authorization Data Access Validation Business Logic

9 Too Many Mixed Responsibilities
(aka Turd Pile) Authorization Data Access Validation Business Logic TIME: 8

10 Layer All The Things Database ASP.NET Auth BLL DAL

11 Layer All The Things ASP.NET BLL DAL Database Auth
Show all the things inside of MVC

12

13

14 Server HTTP Only Clients ASP.NET Database Clients Clients Clients

15 Scheduled / Reoccurring
Non HTTP Requests

16 Minimize Coupling to a Framework

17 Common Interface to Invoke Functionality

18 Why organize by technical concerns?
Layered Technical Concerns Why organize by technical concerns?

19 Simple Changes Layered DAL/ProductModel.cs DAL/ProductRepository.cs BLL/ProductManager.cs MVC/Controllers/ProductController.cs MVC/Views/Products/View.cshtml

20 Layered MVC Auth BLL DAL Database Time: 17

21 Request-Response Controller Uniform API Database

22 CQRS Controller Request Database Auth BLL DAL Should be at 22 minutes

23 Define an object that encapsulates how a set of objects interact
Mediator Pattern Define an object that encapsulates how a set of objects interact

24 Mediator Pattern Object A Object B

25 Mediator Pattern Object A Mediator Object B

26 https://github.com/jbogard/MediatR

27 Should be at 23 minutes

28 Request encapsulates all information required to perform action
Mediator Pattern Request encapsulates all information required to perform action

29 MediatR ASP.NET MediatR Handler Request Request

30 Time: 26

31

32 MediatR Request Caller MediatR Handler Request

33 MediatR Request

34 MediatR Request Handler
Caller MediatR Handler Request

35

36

37

38

39 Time: 34

40

41

42

43 MediatR Behaviors Request Pipelines Caller MediatR Pre Process Handler
Post Process Handler

44 MediatR Behaviors Request Pipelines ASP.NET Core MVC MediatR Handler
Add to Cart Logger

45

46 MediatR Notifications
Handler MediatR Notifications Publish + Subscribe Caller MediatR Handler Notification Handler TODO: Add Diagrams

47 TODO: Add Diagrams

48 TODO: Add Diagrams

49 Organize By Layer Controllers/ShoppingCartController.cs
ViewModels/ShoppingCartViewModel.cs Models/ShoppingCart.cs Views/ShopingCart/Index.cshtml

50 Organize By Feature Features ShoppingCart
AddToCart.cs RemoveFromCart.cs ViewCart.cs ViewCart.cshtml Models ShoppingCart.cs Album.cs CartItem.cs

51

52 Organize By Layer ASP.NET MVC Authorization Validation Data Access
Time = 42 Model Database

53 Organize By Feature Model Database Feature Feature Feature Feature
Time = 42 Database

54 Single Feature Controller Authorization Validation Execution Model
Time = 42 Model Database

55 Single Feature ASP.NET MVC Authorization Fluent Validation
Entity Framework Time = 42 Model Database

56 Single Feature Nancy Authorization Validation Dapper Model Database
Time = 42 Model Database

57 Success! Segregate our code from I/O MediatR between integration boundaries Feature Slices not Layers

58 Trade-Offs & Notes Runtime Exceptions Tests Analyzer DI Container & Registrations

59 Enabler Async, Task Queues, Pub/Sub Multiple Data Model/Stores Dependencies per Command/Query

60 That’s it… Thanks! Derek Comartin @codeopinion codeopinion.com


Download ppt "Vertical Feature Slices Not Layers"

Similar presentations


Ads by Google