Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Error handling for commands #12
The ports and adapters example is really, really great. This series is the most readable assembly of this set of concepts that I have seen so far, and I think this style of architecture is one that people could benefit from using a lot more.
Something I took note of as I was reading through was that you never really touched on error handling. If CQS dictates that no values are returned when you're writing data, what do you do if some invariant is violated and thus you can't write the data?
Do you raise an exception? (which is a kind of return value, albeit one intended for unexpected cases)
Do you instead have validation at another layer, doing a Query to inspect what the command is trying to do before running the Command?
Here's an example: what if the assignee for an issue had to be one of a known list? Where would you check that?
I have thoughts on approaches to this, but I'm curious to know how you handle the situation in the architecture you've built up.
Thanks for putting the effort into this!