Skip to content

Product existence check / Asynchronous domain #31

Answered by kgrzybek
chrishanzlik asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @chrishanzlik

From my experience, the best place to check if something exists is an Application Layer (Application Service / Command Handler). If a product does not exist it means that the command is invalid so the operation should be aborted immediately (fail-fast principle). In Application Service you can use async/await so it will be more efficient too.

However, this is the case when the boundary between the application layer and domain layer is blurry. So you can put this logic in Domain but in my opinion, it is not a good idea and I would stick to the Application Layer. I try to avoid I/O operation in Domain Layer (even hidden behind the interface) and make Domain pure (but this i…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by chrishanzlik
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #29 on February 22, 2021 22:06.