How to get started with CQRS & Event Sourcing

hammernailWhen I first heard about CQRS & Event Sourcing concepts through various blogs and videos, primarily from Greg Young and Udi Dahan, I wanted to apply it everywhere.

It seems really natural to want to take the limited knowledge we have about a new concept or technology and try and apply it to any problem.

Most of us know this is a terrible idea, but we are so tempted to push the concepts on a problem that it just doesn’t fit.

I realize I’m grouping CQRS and Event Sourcing together in this post.  Generally, if you are applying Event Sourcing then you are doing CQRS.  The other way around isn’t always true.

The Problem

In the very beginning I had a difficult time seeing where CQRS and Event Sourcing were best applied.  Again, as a beginner with our new shiny new knowledge we have our blinders on.

We look at any new problem and try to make it fit what we think CQRS and Event Sourcing solves.

There are some pretty good examples scattered around the internet about different situations that CQRS and Event Sourcing have been applied.  You may be able to read these examples and get a better understanding about what the context and how it was a good fit.  Also, you may read horror stories about how it was a complete failure and why.

To be honest, I haven’t read that many horror stories as I assume people are too afraid to admit their failures, although it would be very helpful to the community.

Feeling the Pain

I could read all kinds of blogs about where not to apply CQRS & Event Sourcing, but I need to feel the pain first hand to really understand where it’s best used.

I needed to apply the concepts I read about in a meaningful project.

For me a meaningful project was a side-project I worked on after hours at home that was large enough in scale that wasn’t incredibly trivial.

The learning experience of failure (and success) gave me greater insights and a deeper understanding to the words I’ve previously read from others discussing CQRS & Event Sourcing.

Practice

Start using CQRS and Event Sourcing in a project that is meaningful to you.  Obviously, I’m not recommending it in a project at work.  Do it in on a project where you can fail.  Feel the pain of applying these concepts where they don’t provide enough value or are cumbersome (hint: CRUD).

With real practice, your understanding matures and not everything will look like a nail with your shiny new hammer.