CQRS in a jiffy!

Segregate operations that read data from operations that update data by using separate interfaces. This pattern can maximize performance, scalability, and security; support evolution of the system over time through higher flexibility; and prevent update commands from causing merge conflicts at the domain level. The term sounds heavy, but the concept is not. At least, this is what we discovered at the end of our regular KnolX session that we have at the Knoldus office every Wednesday.

The main ideas are summarized as

  • A method should either change state or return a result, not both
  • Asking a question should not change the answer (SRP + Immutability) – No side effects


  • Commands – change the state of an object or entire system (sometimes called as modifiers or mutators).
  • Queries – return results and do not change the state of an object.

In the real world,

  • Methods which return something are mostly queries – specialized reporting needs
  • Methods which return unit are commands – domain with all the behavior

Looks interesting, go through the slide deck and video below


About Vikas Hazrati

Vikas is the Founding Partner @ Knoldus which is a group of software industry veterans who have joined hands to add value to the art of software development. Knoldus does niche Reactive and Big Data product development on Scala, Spark and Functional Java. Knoldus has a strong focus on software craftsmanship which ensures high-quality software development. It partners with the best in the industry like Lightbend (Scala Ecosystem), Databricks (Spark Ecosystem), Confluent (Kafka) and Datastax (Cassandra). To know more, send a mail to hello@knoldus.com or visit www.knoldus.com
This entry was posted in Scala and tagged , , . Bookmark the permalink.

One Response to CQRS in a jiffy!

  1. Vikas, good stuff! Is the Auction Sample Code available somewhere? May I access it?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s