You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Command Query Separation principle states that each method should be either a command that performs an action or a query that returns data to the caller but not both. Asking a question should not modify the answer.
400
+
401
+
With this principle applied the programmer can code with much more confidence. The query methods can be used anywhere and in any order since they do not mutate the state. With commands one has to be more careful.
402
+
403
+
Why
404
+
405
+
* By clearly separating methods into queries and commands the programmer can code with additional confidence without knowing each method's implementation details.
406
+
407
+
How
408
+
409
+
* Implement each method as either a query or a command
410
+
* Apply naming convention to method names that implies whether the method is a query or a command
411
+
412
+
Resources
413
+
414
+
*[Command Query Separation in Wikipedia](https://en.wikipedia.org/wiki/Command%E2%80%93query_separation)
415
+
*[Command Query Separation by Martin Fowler](http://martinfowler.com/bliki/CommandQuerySeparation.html)
The Command Query Separation principle states that each method should be either a command that performs an action or a query that returns data to the caller but not both. Asking a question should not modify the answer.
407
+
408
+
With this principle applied the programmer can code with much more confidence. The query methods can be used anywhere and in any order since they do not mutate the state. With commands one has to be more careful.
409
+
410
+
Why
411
+
412
+
* By clearly separating methods into queries and commands the programmer can code with additional confidence without knowing each method's implementation details.
413
+
414
+
How
415
+
416
+
* Implement each method as either a query or a command
417
+
* Apply naming convention to method names that implies whether the method is a query or a command
418
+
419
+
Resources
420
+
421
+
*[Command Query Separation in Wikipedia](https://en.wikipedia.org/wiki/Command%E2%80%93query_separation)
422
+
*[Command Query Separation by Martin Fowler](http://martinfowler.com/bliki/CommandQuerySeparation.html)
0 commit comments