Command Query Responsibility Segregation is a fancy pattern name, which means decoupling the input and the output of your system. In CQRS, we mainly talk about the read and write characteristics of our application; so, the commands in the context of CQRS are mainly write operations, while the queries are read operations, and responsibility means that we separate our read and write operations.
If we look at the architecture described in the first section, Introduction, and apply CQRS, the architecture will be divided into half, and would look something like this:
Now we will look at some code examples.
A traditional interface module would look something like this:
Class managementservice(interface): Saveuser(userdata); Updateuser(userid); listuserbyusername(username); listuserbyid(userid);
Split-up, or as I prefer to call them, CQRS...