Search code examples
design-patternsdomain-driven-designcqrscommand-query-separation

How to identify if a project has used CQS OR CQRS? What is the difference between CQS and CQRS?


I might sound dumb with this question but i am really confused. Does creating a command,query,commandhanlder,queryhandler and repositories and using dependency injection to resolve queryhandlers and commandhandlers based on query and command respectively qualify as cqs or cqrs ?

Or Using Task Parallel library for command and query handlers qualify as cqrs than cqs ?

Or Is it really based on Use Case whether there is a scenario of collaborative domain --> Multiple users trying to access limited data.


Solution

  • CQS says your command methods should not return anything (be void) and only mutate the object state. Query methods should return results and query method calls should be immutable, query method does not change the object state. This is it.

    CQRS is "splitting a model object into two". You will have one model to write and one model to read, which are completely separate. You might store your data in the same database, but where you write to using your commands is separated from where you read from using your queries, they use different models (write and read).