This is a continuation of the text about the architecture of interprise systems. Reasoning is good, but what's the point without practical application. I'll show my framework in action.
It all started when I talked about the problems of designing applications in .NET and whined about the difficult life in a bloody enterprise. Then I described the solution I came up with and implemented myself - Reinforced.Tecture. It was theory, conceptual reasoning, visionary and whining again. This time it's about 2020, and HKT hasn't been delivered to C #.
Today I will demonstrate my approach in action using a simple project as an example and show the benefits that it gives: from reducing the amount of code to testing automation and an original approach to documentation. As old Torvalds advised: "Chatting is worthless, show me the code."
So, we need to do something simple, but working in Tecture. Since we are talking about an enterprise, I will choose an example that vaguely resembles a real business.
We need:
- Simple essence. Products and orders immediately come to mind. Let there be products;
- EF DbContext and local database;
- Toy business logic;
- A simple web project. All rank by rank, ASP.NET Core, WebAPI. We'll stick the logic into it.
Training
The project structure will be as follows:
I connected EF.Core to the assembly Data
, put DbContext and glue code for migrations there. Because I want to leave the logic on .NET Standard and not drag EF with me.
DAL-, . — . , Tecture. .
We will look at Tecture behavior using an example of working with products. Here is its essence, and the logic around it will be simple and very stupid:
DbContext
- , - . — . EF , . . EF — ORM-. EF-.
MS SQL Express. — . EF.Core - — MySQL PostgreSQL. , , Tecture, . . .
, . Reinforced.Tecture Reinforced.Tecture.Aspects.Orm.
. , O/RM:
, Id. , . :
. Tecture end-user . web-. , Startup.cs
, ConfigureServices
. DI-, ASP.NET MVC. , AcmeDbContext
:
Tecture EF. web-. 2 : O/RM DirectSQL. DirectSQL , . , - . , - , dll- . . — — :
Tecture . . . AcmeDbContext
, LazyDisposable
( Lazy Disposable, ) . , EF . fluent-:
. " " . , , Tecture, , . separation of concerns: , , — — . , — , .
. , . , . , , , . — . , separation of concerns .
, : , , . glue-. , — , .
Tecture , . .
, ITecture
. .
-, Id. , . DTO. , , :
, ITecture
, , From<>
. , Id DTO-:
, , . Id DTO- . C# . , DTO- :
:
IQueryable
, All<>
, . . — , . — AutoMapper, expression-. — . , . , . , . , .
, - . . , Tecture . . , :
, . . ORM- — :
, Id . ORM — . — , Id — . ? : Add
IAddition<>
. , IAddition<Product>
. Key
. Id. . IPrimaryKey<>
. :
. - :
Postman Id .
-, Tecture. , , . — , .
. , .
. . 90% . , , — , .
, — . — . — .
.
. Tecture BeginTrace
EndTrace
. . :
Explain
. Tecture . return
:
! . , - . , , , — , , , . , , :
.Describe
.
: - . , , , . — , .
, , . , . , . , .
Tecture : . . -, . , - , . , . , , . Knowledge management!
IDescriptive
, , , . "User entity" "User Vasiliy Pupkin". , . , .
, - . Explain
— , , . , : , .
.
. . web- : Reinforced.Tecture.Testing
. — Roslyn. , . :
2 . GenerateData
GenerateValidation
. , :
: , C#-. , Tecture fake- . , , , -, Mockaroo. - — . , ?
. Reinforced.Tecture.Testing
. , 4 :
: -, - ( + ). . !
, . - -. , .
, ...
Unit-
, . QA : ", , !". , , , unit-.
CI/CD — . , , , . . . , Tecture . : - , . — . .
— , , - . , , , . — — , .
. . .
— , GenerateData
GenerateValidation
. NuGet . , .
, :
, :
, unit- 5 . , .
, ( ). - unit-. , , , - .
.
-
. , . , .
, Tecture. , . , — , . .
— , DirectSql, . , . .
The packages have been published, the sources are there , I am in touch on twitter, telegram and on github. If you suddenly want to join the ranks of early adopters and take Tecture for your pet project - write to me, I will try to help.
Special thanks fillpackart, arttomand their We Are Doomed community for informational support and editing. Watch their podcast , it's awesome. There is even a release with me .
Good luck!