Skip to content

Conversation

@chlgkrws
Copy link

@chlgkrws chlgkrws commented Jul 9, 2023

Hello,

I hope this message finds you well and enjoying your weekend. I am a backend developer from South Korea who has been studying Hexagonal Architecture and gaining various insights through your Modular-Architecture-Hexagonal-Demo-Project.

While studying your source code, I pondered on the part about input validation. Since the UseCaseHandler is called through the publisher, it seems we have to do input validation twice: once at the REST level, and then again at the UseCaseHandler level.

I found this situation to be quite inefficient. Consequently, I thought of creating an isSatisfied method in the UseCase interface, which is invoked within the Publisher method prior to calling the handle method of UseCaseHandler. This approach seems to streamline the process of validating input values, avoiding unnecessary repetitions.

With this approach, the following benefits were observed:

We can directly bind from the API to the UseCase.
We can achieve unified domain UseCase input validation.
We can focus the business logic in UseCaseHandler.
I have applied these thoughts in code and am submitting them in this Pull Request. As I am not very experienced, I may not have considered all perspectives. Even if this does not contribute directly, I would very much appreciate your candid feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant