iOS and Mac apps rely heavily on state to change their presentation and respond to input—it’s hard to imagine writing an app without the use of properties and variables. However, state is also a huge source of needless complexity, and responsible for most of the easily avoidable bugs that users encounter. Think about how many times you’ve heard “turn it off and on again” as the way to solve a problem—and furthermore, how many times it’s actually worked!
“Enemy of the State” is a talk I created and presented multiple times in 2014, in which I explain what state is, detail exactly why it’s so harmful, and offer ways to minimize and avoid state—making the apps we develop simpler and more reliable.
This presentation is primarily aimed at Cocoa (iOS and macOS) developers, but the fundamental concepts, and the discussion of how state breeds complexity, apply to all of software engineering.
Here are some of the materials referenced in the talk:
- Simple Made Easy by Rich Hickey
- Out of the Tar Pit by Moseley and Marks
- Mutability, aliasing, and the caches you didn’t know you had by Andy Matuschak
- Boundaries by Gary Bernhardt
- “Advanced iOS Application Architecture and Patterns” from WWDC 2014 by Andy Matuschak and Colin Barrett
- Haskell’s official website, or my preferred tutorial, Real World Haskell