Lately, I've been a bit obsessed with Command-Query Responsibility Segregation (CQRS). I'm not quite sure if I'm late to the party or jumping on the bandwagon because I remember seeing a lot of noise around CQRS in my RSS feed a few months ago but didn't really bother with it at the time. I'm not sure if it's still a hot topic or was a passing fad, but the more I read about it, the more interested I become. I agree with a lot of the architectural principles, but I'm not going to re-hash those.
For anyone that wants to learn more about CQRS,
http://cqrsinfo.com/ is a great starting place. There are also great blogs out there maintained by
Greg Young,
Rinat Abdullin,
Mark Nijhof,
Jonathan Oliver and
Udi Dahan - all of whom are far more knowledgeable on the subject than I am.
When you read about CQRS, you usually see what I call the full monty which includes using event sourcing (capturing all changes to an application state as a sequence of events), using separate databases for the read side and the write side and even distributing the application in the cloud. There are very compelling benefits to using the full monty, but at the same time, I think there are benefits to using bits of the CQRS architecture without going all out. So what I hoped to write about in these next few blog posts is dissecting some of the steps you can take in your code to achieve some of the benefits of CQRS without necessarily making it all or nothing proposition.
Allow me to reiterate - no CQRS information I've read has ever said that you need to do all the steps to see benefits in your application. As a matter of fact, some things I've read have discussed the benefits as being independent. I've just rarely seen the steps you can take broken out into logical pieces and the benefits of each discussed. That's what I hope to do with this blog series.
Lastly, I hope to get some feedback from people with far more CQRS experience than I have. If something I say sounds completely wrong, I'd love to know about it. I'm just trying to distill the large amount of information I've digested into something that makes sense to me. So I may have gotten something confused in all of my reading and I don't claim to be an expert.
My next post will talk through the first step I see towards CQRS - which is the most straightforward one... separating your reads from your writes.
- Introduction
- Step 1: Separating Your Reads From Your Writes
- Step 2: Commands, Events And Handlers