Another Word For It Patrick Durusau on Topic Maps and Semantic Diversity

March 3, 2014

CQRS with Erlang

Filed under: Erlang,Functional Programming — Patrick Durusau @ 7:47 pm

CQRS with Erlang by Bryan Hunter.

Summary:

Bryan Hunter introduces CQRS and one of its implementations done in Erlang, outlining the areas where Erlang shines.

You will probably enjoy this presentation more after reading: Introduction to CQRS by Kanasz Robert, which reads in part:

CQRS means Command Query Responsibility Segregation. Many people think that CQRS is an entire architecture, but they are wrong. CQRS is just a small pattern. This pattern was first introduced by Greg Young and Udi Dahan. They took inspiration from a pattern called Command Query Separation which was defined by Bertrand Meyer in his book “Object Oriented Software Construction”. The main idea behind CQS is: “A method should either change state of an object, or return a result, but not both. In other words, asking the question should not change the answer. More formally, methods should return a value only if they are referentially transparent and hence possess no side effects.” (Wikipedia) Because of this we can divide a methods into two sets:

  • 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 a real situation it is pretty simple to tell which is which. The queries will declare return type, and commands will return void. This pattern is broadly applicable and it makes reasoning about objects easier. On the other hand, CQRS is applicable only on specific problems.

Demo Code for the presentation.

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress