CQRS in a jiffy!

Table of contents
Reading Time: < 1 minute

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


Written by 

Vikas is the CEO and Co-Founder of Knoldus Inc. 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). Vikas has been working in the cutting edge tech industry for 20+ years. He was an ardent fan of Java with multiple high load enterprise systems to boast of till he met Scala. His current passions include utilizing the power of Scala, Akka and Play to make Reactive and Big Data systems for niche startups and enterprises who would like to change the way software is developed. To know more, send a mail to hello@knoldus.com or visit www.knoldus.com

1 thought on “CQRS in a jiffy!1 min read

Comments are closed.