Example: migrating from REST to GraphQL, or serving them both simultaneously!
- the domain logic that specifies how to create a comment
- the application logic that specifies what should happen
- we have to repeat the validation logic in every controller (- maintainability)
- we have to **remember** to call upon the validation logic (- security)
- increases file size & duplication (- size)
- there's no architecture! (- maintainability)
- Inner layers are responsible for application & domain logic.
- Validation logic is represented as a domain concept in a Value Object.
khalilstemmler.com/articles/types…
Every command has one way it can go right, and at least one way it can go wrong- usually more. Those ways it can go wrong deserve to be strictly typed so that we can map 'em to error responses.
khalilstemmler.com/articles/enter…
Types are a good programming practice. With types, we can do something that comments can't: enforce policy.
We can make it virtually impossible to perform illegal operations
khalilstemmler.com/articles/types…
github.com/stemmlerjs/ddd…
As for handling the side-effects of issuing this use case, like sending a slack message once the comment is posted, it's best to use some form of the Observer pattern.
khalilstemmler.com/articles/types…