Where is the best position of validation code?
BrianDYKim opened this issue · 1 comments
BrianDYKim commented
Preview
Now, I'm refactoring Validators using webClient (Spring5 Stack) to gRPC (messaging IPC) when validating whether the specific item exists or not.
Problems i have are followings:
- gPRC interface is in independent:grpc-interface module now.
- Validator code is used in Service layer, but gRPC is IPC Protocol used in between adapter:router-command and adapter:router-query
- So, it seems that might be appropriate if the validator logics are moved to adapter layer
What can I do to solve this problem
Now, validator classes are in domain layer, but by the principle of Hexagonal Architecture, domain layer must not have any dependencies with anywhere. (including dependencies to outside of code-level)
So, I will segregate the validator codes from domain layer and put these things in adapter:router-command and port:service-command each others:
- Put the interfaces of validator code in port:service-command
- Put the implementation classes of the validator interfaces in adapter:router-command
Then, it might be more clean architecture than before.
BrianDYKim commented
solved.