thePHP.cc Logo Deutsch Contact Menu
mood

CQRS

Command/Query Responsibility Segregation (CQRS) is an architectural principle named by Greg Young. It is based on the CQS principle (Command-Query Separation) formulated by Bertrand Meyer in the 1980s. Here, operations that change the state (commands) are strictly separated from queries that do not cause a significant change in state.

It is interesting that the CQS principle, which ultimately proposes the separation of getters and setters (actually: mutators), is intuitively implemented by many developers at the object level, while this separation is made much less frequently at the application level. Nevertheless, this is particularly obvious for web applications, since the HTTP protocol also provides for a strict separation of reading (GET) and writing (more generally: state changing) methods such as POST.

The application of CQRS principles not only improves the design, because it suggests the creation of several lean and simple models ("multiple models"), but can also improve security in many use cases, because write operations are not possible in the first place, because there are no methods for them in the first place.

Training

Use these design patterns to develop your applications faster and better understand common frameworks.

More training
Article Improve Your Design with CQRS More articles
Presentation Introducing CQRS into Legacy Code More presentations