4

CQRS in a jiffy!

 3 years ago
source link: https://blog.knoldus.com/cqrs-in-a-jiffy/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

CQRS in a jiffy!

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


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK