Lets assume that we have several commands sharing common logic. For example i have Document that have several states. We have mutating operation that is possible on some states, but some of the logic is different depending on its state. Making one Command
using If
statements for more than 3 states is confusing. Its better for each operation make separate command, but what to do with common logic ?
We have to fetch data from DB, validate, generate some side documents, write to audit table and other stuff. So it looks like it should be common place and making meaningless Helper
class is the worst option. I assume that this operations can / don't require transaction.
I have read http://scrapbook.qujck.com/holistic-abstractions-take-2/ and CQRS code duplication in commands . I am looking for other options.