Lecture thumbnail 0:00 / 0:00 So one thing worth mentioning is something called command query separation, a very well known and popular
idea.
So the idea is that whenever we operate on objects, we separate all of the invocations into two different
concepts which are called query and command.
So a command is something that you send when you’re asking for an action or a change.
So, for example, you want to set the attack value of a creature to two.
So you’re sending a command which specifies that you need to modify.
The thing you need to modify is the attack value and the new value you want to set.
It is equal to two.
Another thing is query and query is asking for information without necessarily changing anything.
So you simply asking for the system to give you a particular value, like please give me your attack
value.
And so we have something called SQS, which means that you have separate means of sending commands and
queries.
So instead of, for example, directly accessing a field of a particular class, what you do is you
send it a message.
Either you send it a message telling you to please give me the contents of the field, or you send a
command, which states please set the field to this particular value.
And thanks to the chain of responsibility, you can also have other listeners to this command being
sent and they can override the behavior of the actual command or indeed the query.
Play Stop Play Play Start Play information alert