Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Command–query separation
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|IT architecture separating actions and reads}} {{refimprove|date=February 2008}} '''Command-query separation''' ('''CQS''') is a principle of [[Imperative programming|imperative]] [[computer programming]]. It was devised by [[Bertrand Meyer]] as part of his pioneering work on the [[Eiffel (programming language)|Eiffel programming language]]. It states that every [[Method (computer science)|method]] should either be a ''command'' that performs an action, or a ''query'' that returns data to the caller, but not both. In other words, ''asking a question should not change the answer''.<ref>{{cite web |last=Meyer|first=Bertrand|title=Eiffel: a language for software engineering|url=http://laser.inf.ethz.ch/2012/slides/Meyer/eiffel_laser_2012.pdf|page=22|access-date=16 December 2014}}</ref> More formally, methods should return a value only if they are [[Referential transparency|referentially transparent]] and hence possess no [[Side effect (computer science)|side effect]]s.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)