❔ Should I make more transfer classes between layers?
This is also a more general question of whether my architecture makes sense.
I based it on Clean Architecture. (Similar to https://github.com/jasontaylordev/CleanArchitecture)
I have layers:
-Web
-Application
-Infrastructure
-Domain
In domain I have entities declared and domain services / aggregators and validators that deal with business logic.
Entities have very basic business logic, concerning only this entity but most of logic is in services/aggregators.
In application I have commands and queries where I call methods from the domain and eventually map to a DTO that comes out to web.
In application I also receive domain events to, for example, log what happened.
However, I have a problem. Suppose I have a class Car. To it I have a carService that, using the repository, adds, edits or retrieves cars.
And the method is, for example, _carService.UpdateCar(id, name, color, ... 10 more props) or identical _carService.AddCar(name, color, ... 10 more)
I would like to call this in a handler in the application, but passing so many parameters does not appeal to me. What is the best approach? Should I make another transfer class between the application and domain layer?
I was thinking to maybe creating record for such methods, that will act as transfer model for data.
But maybe I should create additional CarEntity, that will only act as transfer from/to DB?
The application will be large and developed over the years. Currently it contains more than 50 different types of entities.
Does my architecture more or less make sense?
I based it on Clean Architecture. (Similar to https://github.com/jasontaylordev/CleanArchitecture)
I have layers:
-Web
-Application
-Infrastructure
-Domain
In domain I have entities declared and domain services / aggregators and validators that deal with business logic.
Entities have very basic business logic, concerning only this entity but most of logic is in services/aggregators.
In application I have commands and queries where I call methods from the domain and eventually map to a DTO that comes out to web.
In application I also receive domain events to, for example, log what happened.
However, I have a problem. Suppose I have a class Car. To it I have a carService that, using the repository, adds, edits or retrieves cars.
And the method is, for example, _carService.UpdateCar(id, name, color, ... 10 more props) or identical _carService.AddCar(name, color, ... 10 more)
I would like to call this in a handler in the application, but passing so many parameters does not appeal to me. What is the best approach? Should I make another transfer class between the application and domain layer?
I was thinking to maybe creating record for such methods, that will act as transfer model for data.
But maybe I should create additional CarEntity, that will only act as transfer from/to DB?
The application will be large and developed over the years. Currently it contains more than 50 different types of entities.
Does my architecture more or less make sense?