Command query separation | Glossary

Definition:

Bertrand Meyer devised CQS, or Command Query Separation, as part of his work on the Eiffel programming language.

The fundamental idea is that we should divide an object’s methods into two sharply separated categories:

  • Queries: Return a result and do not change the observable state of the system (are free of side effects).
  • Commands: Change the state of a system but do not return a value.

Further Reading:

Book: Applying UML and Patterns by Craig Larman

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.