Mindful Functions
TL;DR: break code into short functions with scalar parameters and good names, and coordinate them
Mindful means, for a human, to focus on the immediate environment, task, and intention: to be “present in the moment”. For a function, it means to do one operation and to return the consequence of that operation. This is quite close to Functional Programming’s definition of a pure function (side-effects withstanding). F.P.‘s prime benefit is the isolation of the operation; mindfulness’ prime benefits are attention, modularity, and scope
Each function or method should do one thing1. The implementation of that one thing might be calling other functions. For example, a function prepare_order()
calls other functions to process every step of the order; it never actually changes or creates data itself, yet it completes a single conceptual task by orchestrating sub-functions
Hierarchical Code
...