There are two basic ideas in CQRS:
- Objects should not have direct access to view or modify other object’s state.
- There should be separate codes to get (query) or modify (command) the state of an object. In simple word, Command method is Void, where, Query method has a return type.
So, how does an object can interact with other parts of the code if they do not have access to its fields? The answer is: “through Events”.
Classes should listen to specific types of events which are propagating in the system and act upon or reply to them.