https://abs.twimg.com/emoji/v2/... draggable="false" alt="📔" title="Notizbuch mit verziertem Umschlag" aria-label="Emoji: Notizbuch mit verziertem Umschlag"> The Command-Query Separation (CQS) principle says: functions should do something or answer something, not both.

https://abs.twimg.com/emoji/v2/... draggable="false" alt="🔹" title="Kleine blaue Raute" aria-label="Emoji: Kleine blaue Raute">Commands: change state and don& #39;t return anything.
https://abs.twimg.com/emoji/v2/... draggable="false" alt="🔹" title="Kleine blaue Raute" aria-label="Emoji: Kleine blaue Raute">Queries: return a result and don& #39;t change state. They& #39;re free of side effects.

If you break the CQS... https://abs.twimg.com/emoji/v2/... draggable="false" alt="🧵" title="Thread" aria-label="Emoji: Thread"> 1/3
https://abs.twimg.com/emoji/v2/... draggable= The Command-Query Separation (CQS) principle says: functions should do something or answer something, not both.https://abs.twimg.com/emoji/v2/... draggable="false" alt="🔹" title="Kleine blaue Raute" aria-label="Emoji: Kleine blaue Raute">Commands: change state and don& #39;t return anything.https://abs.twimg.com/emoji/v2/... draggable="false" alt="🔹" title="Kleine blaue Raute" aria-label="Emoji: Kleine blaue Raute">Queries: return a result and don& #39;t change state. They& #39;re free of side effects.If you break the CQS... https://abs.twimg.com/emoji/v2/... draggable="false" alt="🧵" title="Thread" aria-label="Emoji: Thread"> 1/3" title="https://abs.twimg.com/emoji/v2/... draggable="false" alt="📔" title="Notizbuch mit verziertem Umschlag" aria-label="Emoji: Notizbuch mit verziertem Umschlag"> The Command-Query Separation (CQS) principle says: functions should do something or answer something, not both.https://abs.twimg.com/emoji/v2/... draggable="false" alt="🔹" title="Kleine blaue Raute" aria-label="Emoji: Kleine blaue Raute">Commands: change state and don& #39;t return anything.https://abs.twimg.com/emoji/v2/... draggable="false" alt="🔹" title="Kleine blaue Raute" aria-label="Emoji: Kleine blaue Raute">Queries: return a result and don& #39;t change state. They& #39;re free of side effects.If you break the CQS... https://abs.twimg.com/emoji/v2/... draggable="false" alt="🧵" title="Thread" aria-label="Emoji: Thread"> 1/3" class="img-responsive" style="max-width:100%;"/>
Potential problems:

https://abs.twimg.com/emoji/v2/... draggable="false" alt="🔹" title="Kleine blaue Raute" aria-label="Emoji: Kleine blaue Raute">Unclear whether functions have side effects.
https://abs.twimg.com/emoji/v2/... draggable="false" alt="🔹" title="Kleine blaue Raute" aria-label="Emoji: Kleine blaue Raute">Function names are often deceiving: functions do more than they say.
https://abs.twimg.com/emoji/v2/... draggable="false" alt="🔹" title="Kleine blaue Raute" aria-label="Emoji: Kleine blaue Raute">Violations of Single Responsibility Principle.
https://abs.twimg.com/emoji/v2/... draggable="false" alt="🔹" title="Kleine blaue Raute" aria-label="Emoji: Kleine blaue Raute">Temporal couplings: the order in which you call functions with side effects matters. 2/3
https://abs.twimg.com/emoji/v2/... draggable="false" alt="✏️" title="Bleistift" aria-label="Emoji: Bleistift"> Coding tip: follow CQS whenever possible, but don& #39;t be too dogmatic. In some cases, it does not fit well.

Example: popping the top element of a stack. The "pop" function removes one element and returns it. Therefore, it modifies the state of the stack and returns a value. 3/3
You can follow @macerub.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled: