Skip to content

Create Request/Response DTOs for Application Services #25

@JavierCane

Description

@JavierCane

What

Instead of instantiating the Value Objects directly from the controller, we should instantiate a DTO such as SignUpUserRequest and pass it to the Application Service.

The Application Services intended for querying data, we should return also a DTO such as UserResponse.

Why

This way we:

  • Avoid coupling our entry points to the internal details on how we model out our domain (UserId value objects and so on).
  • Leave the code on the Hexagonal Architecture approach closer to what we'll do while evolving to an architecture applying CQRS concepts. We will only need to:
    • Replace the XxxRequest by their corresponding XxxCommand,
    • Send the commands to the Command Bus instead of directly calling the Application Service
    • Implement the Command Handler in order to extract each one of the scalar values from the Command, convert them to Value Object instances, and call to the Application Service
    • Modify the Application Service in order to directly receive the Value Objects instead of the XxxRequest

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions