You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are currently learning Clean Architecture and have found the DDD Fundamentals course helpful in understanding the concepts. We’re now in the early stages of building a new service following the Clean Architecture template, but we have some questions about mapping complex JSON objects from Web endpoints to the UseCases layer.
For example, let’s say we have an Order entity with multiple properties, including a list of OrderLines, and in the Core layer, we treat Order as an Aggregate Root. The JSON object we receive at the Web endpoint could look like this:
In the Clean Architecture template, we see that properties like this map to a CreateOrderRequest DTO, and are then passed as parameters to a CreateOrderCommand in the UseCases layer. However, with a more complex Order object, we want to pass the entire object rather than mapping each individual property to a parameter. We see that the FrontDesk solution from the DDD course uses AutoMapper in the API layer but doesn’t incorporate a separate UseCases project for orchestration. We'd like to follow the UseCases logic but are unsure of the best way to handle the object mapping.
Given that we want to keep the Web endpoints minimal, what’s the recommended approach for mapping complex JSON (e.g., Order and OrderLines) to a Command in the UseCases layer? Should this mapping occur in the Web project, or is it better practice to handle it in the UseCases layer? Additionally, should we use an Order DTO, or should we map directly to the Core Order model?
Any recommendations/input would be appreciated.
Thanks!
Stephanie
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
We are currently learning Clean Architecture and have found the DDD Fundamentals course helpful in understanding the concepts. We’re now in the early stages of building a new service following the Clean Architecture template, but we have some questions about mapping complex JSON objects from Web endpoints to the UseCases layer.
For example, let’s say we have an Order entity with multiple properties, including a list of OrderLines, and in the Core layer, we treat Order as an Aggregate Root. The JSON object we receive at the Web endpoint could look like this:
In the Clean Architecture template, we see that properties like this map to a CreateOrderRequest DTO, and are then passed as parameters to a CreateOrderCommand in the UseCases layer. However, with a more complex Order object, we want to pass the entire object rather than mapping each individual property to a parameter. We see that the FrontDesk solution from the DDD course uses AutoMapper in the API layer but doesn’t incorporate a separate UseCases project for orchestration. We'd like to follow the UseCases logic but are unsure of the best way to handle the object mapping.
Given that we want to keep the Web endpoints minimal, what’s the recommended approach for mapping complex JSON (e.g., Order and OrderLines) to a Command in the UseCases layer? Should this mapping occur in the Web project, or is it better practice to handle it in the UseCases layer? Additionally, should we use an Order DTO, or should we map directly to the Core Order model?
Any recommendations/input would be appreciated.
Thanks!
Stephanie
Beta Was this translation helpful? Give feedback.
All reactions