
Command Query Separation Pattern

#89 - Code That Fits in Your Head - Mark Seemann
Topic 10 of 11
Published May 23, 2022 · Clip 45:07–49:41 (4:34)
Mark explains command query separation, an idea from Bertrand Meyer (inventor of Eiffel) from the mid-1980s: commands change the state of the observable universe (side effects), while queries return data. Each method should do one or the other, not both. The benefit in statically typed codebases: void methods are known to have side effects, and methods returning data are safe to call without reading implementation—saving reading time and reducing surprises.