In attempt to understand CQRS I created a small application which has Command Executor and event source. By my understanding the changes in domain model are triggered through commands. The domain model then generates the events to update the read model using denormalizer.
But in many cases there may be updates which are non-trivial for the domain. Like user changing his own profile picture. For requirements like these, what is the best way to implement?
I believe that using command will be overkill because the domain model as such doesn’t change.
I tried to search for this question but didn’t find the answer…
Don’t mix CQRS and CRUD. Either the Bounded Context is suitable for CQRS or it’s not. Your pet project probably isn’t. But once you decide to apply the CQRS architecture style, you should stick with it.
Commands are trivial. And since you’re already using Event Sourcing as well (which is not a prerequisite for CQRS btw.) you shouldn’t bypass it for single use cases. Things rapidly become quite messy once you have multiple philosophies in place.
As far as directly writing to the Read Model goes: What if your Read Model goes out of synch, gets corrupted or must be modified and you have to rebuild it? If there’s no related event, how should the Read Model know that something happened then?
There is one thing you can bypass if there’s no domain behavior: You can just use a Transaction Script (POAA) in your command handler and publish the event from there without invoking the domain.
Long story short: You can happily mix styles in multiple isolated parts of your application (i.e. CQRS in one BC, CRUD in another) but inside a single BC you should stay consistent.