In lesson 4.10.1 you created the repository kladde-styles, broke the follow-up down into use cases and test cases, and set the measurement
sheet. Now comes the first version, and it is the one you will meet most often in other people's code: three layers, presentation, business
logic, data access.
You build it the way it really looks in many projects, not in its best conceivable form. That is deliberate. Only this way do you see the
typical decay that the styles of the next lessons were invented against, and only this way is the comparison honest. At the end stands
version A with the tags a-before and a-after in kladde-styles, and column A of the measurement sheet is filled.
Three layers
Microsoft's guide "Common web application architectures" (under Further reading) describes the most widespread order like this: the user interface (UI) talks only to the business logic (BLL), the business logic calls data access (DAL), and the UI never accesses the data itself, not even by detours. Every layer thus has a known job. For the follow-up that makes three projects:
| Project | Layer | Content | references |
|---|---|---|---|
FollowUps.Web |
presentation | Program.cs, the endpoints, request and response types |
FollowUps.Business |
FollowUps.Business |
business logic | FollowUpService with the rules, error codes, Result, the type for the list |
FollowUps.Data |
FollowUps.Data |
data access | FollowUpEntity, FollowUpsDbContext, FollowUpRepository |
EF Core with SQLite |
a-layers/
Layers.slnx
src/
FollowUps.Web/ Program.cs, FollowUpEndpoints.cs
FollowUps.Business/ FollowUpService.cs, FollowUpErrors.cs, Result.cs, DueFollowUp.cs, BusinessRegistration.cs
FollowUps.Data/ FollowUpEntity.cs, FollowUpsDbContext.cs, FollowUpRepository.cs, DataRegistration.cs
tests/
FollowUps.Business.Tests/
FollowUps.Web.Tests/
The same guide names the price right away: the dependencies at compile time run from top to bottom. The business logic, usually the most important code of the application, thus depends on the details of data access and often on the existence of a database, and its test often needs a test database. Keep that sentence in mind; in this lesson you will measure it.