Add mermaid diagrams of before (DbBase inheritance) and after (DTO + mappers) situation
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
%% After: Client and Order become plain domain objects (no DbBase inheritance).
|
||||
%% Dedicated *Dto classes carry data to/from the WebApp, and a mapper converts
|
||||
%% each way, including the relations. EF dependency isolated to persistence layer.
|
||||
classDiagram
|
||||
class DbContext {
|
||||
+SaveChangesAsync()
|
||||
}
|
||||
class DbBase {
|
||||
+Guid id
|
||||
}
|
||||
class WebApp {
|
||||
<<Web App>>
|
||||
}
|
||||
class Client {
|
||||
+Guid id
|
||||
+string name
|
||||
}
|
||||
class Order {
|
||||
+Guid id
|
||||
}
|
||||
class ClientDto {
|
||||
+Guid id
|
||||
+string name
|
||||
}
|
||||
class OrderDto {
|
||||
+Guid id
|
||||
+ClientDto client
|
||||
}
|
||||
class Mappers {
|
||||
+ClientDto ToClientDto(Client c)
|
||||
+Client FromClientDto(ClientDto dto)
|
||||
+OrderDto ToOrderDto(Order o)
|
||||
+Order FromOrderDto(OrderDto dto)
|
||||
}
|
||||
|
||||
DbContext ..> DbBase : still used by persistence layer
|
||||
WebApp --> ClientDto
|
||||
WebApp --> OrderDto
|
||||
WebApp --> Mappers
|
||||
Mappers <--> Client : maps each way
|
||||
Mappers <--> ClientDto : maps each way
|
||||
Mappers <--> Order : maps each way
|
||||
Mappers <--> OrderDto : maps each way
|
||||
Client "1" --> "*" Order : has many (domain relation)
|
||||
ClientDto "1" --> "*" OrderDto : has many (DTO relation)
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 160 KiB |
@@ -0,0 +1,28 @@
|
||||
%% Before: WebApp's domain classes inherit from DbBase (EF),
|
||||
%% which depends on DbContext. Relations live inside the DB-backed classes.
|
||||
classDiagram
|
||||
class DbContext {
|
||||
+SaveChangesAsync()
|
||||
}
|
||||
class DbBase {
|
||||
+Guid id
|
||||
}
|
||||
class WebApp {
|
||||
<<Web App>>
|
||||
}
|
||||
class Client {
|
||||
+Guid id
|
||||
+string name
|
||||
}
|
||||
class Order {
|
||||
+Guid id
|
||||
}
|
||||
|
||||
DbBase --> DbContext : uses (EF)
|
||||
WebApp ..> DbBase : depends on
|
||||
Client --|> DbBase : inherits
|
||||
Order --|> DbBase : inherits
|
||||
WebApp --> Client
|
||||
WebApp --> Order
|
||||
Client "1" --> "*" Order : has many
|
||||
Order "*" --> "1" Client : open / close
|
||||
Reference in New Issue
Block a user