Introduction
Principles
Separation of concerns should be of different parts i.e DataLayer, Logging, Authentication.
SOLID Patterns
Don't repeat yourself
Explicit Dependencies: classes should have injection whenever they need outside resources, files, config, etc. nothing from outside should be directly used in the class.
Onion Architecture
What you do is Interfaces
How you do is Implementation and Most of how you do like boilerplate like data access, logging, etc should be in infrastructure.
Abstraction of data access Repository Pattern.
Clean architecture has 4 parts; Domain, Application, Infrastructure, and Presentation. Domain has enterprise specific code, independent of everything, can be shared to multiple applications. Application layer is application specific; i.e ASP.NET Core Framework, Controllers etc. Infrastructure contains everything of outside world, database/persistence, Authentication/Authorization and injected into the other layers via DI. and Presentation just contain presentation logic.
Domain and Application make up to the core of the system. Infrastructure and Presentation are dependent on that.
Domain Should have
- Entreprise logic and types Contains - Commons -- ValueObject.cs: Base type for all value types -- AuditableEntity.cs: Base entity for all domain entity, has created by, on and updated by and on. - Entities - Value Objects - Internal Models for usage - Enums - Exceptions : Custom Domain Exceptions Key Points - Should Not use data annotation in domains use fluent instead. - Use value objects not primitive types when appropriate. - Create Custom domain exceptions - Initialize all collections and use private setters - Automatically track changes with Auditable entity basetype
Application - Business logic and types Contains CommonFolder - Behavouir - Logging - FeatureFolder - Commond - Querries -- DTO : IRequest -- Handler is IRequestHandler - Interfaces: - Models: - Logic: - CQRS: -- Command Query Request Segregation -- Separate reads (Query) from writes (Commands) -- Maximize scalability, performance and simplicity. - Mediator - Validators: Infrastructure - All external concerns - Database - Identity - DI for all thosePresentation - UI Area
Tests - Application
- Entreprise logic and types
Contains
- Commons
-- ValueObject.cs: Base type for all value types
-- AuditableEntity.cs: Base entity for all domain entity, has created by, on and updated by and on.
- Entities
- Value Objects - Internal Models for usage
- Enums
- Exceptions : Custom Domain Exceptions
Key Points
- Should Not use data annotation in domains use fluent instead.
- Use value objects not primitive types when appropriate.
- Create Custom domain exceptions
- Initialize all collections and use private setters
- Automatically track changes with Auditable entity basetype
Application
- Business logic and types
Contains
CommonFolder
- Behavouir
- Logging
-
FeatureFolder
- Commond
- Querries
-- DTO : IRequest
-- Handler is IRequestHandler
- Interfaces:
- Models:
- Logic:
- CQRS:
-- Command Query Request Segregation
-- Separate reads (Query) from writes (Commands)
-- Maximize scalability, performance and simplicity.
- Mediator
- Validators:
Infrastructure
- All external concerns
- Database
- Identity
- DI for all those
Presentation
- UI Area
No comments:
Post a Comment