Design Patterns · Senior · Question 31 of 75

What does the Command-Query Separation (CQS) principle require?

Explanation

A query function without side effects is predictable and safe to call repeatedly (e.g. during render). There are exceptions (stack.pop()), but the principle helps avoid surprises like a getter that makes a request. CQRS is the architectural extension of this idea.

Further reading

Problem with a question

Design Patterns · Senior · question 31

Test yourself

Take the Design Patterns · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz