Narrative arcs in the code
A good method has narrative structure. There’s an establishing scene, a rising action, and a conclusion to tie up loose ends. After reading more fiction recently, I’ve been finding fictional story structure seep into my code - for the better.
In the narrative, a good author keeps the outside information to a minimum. The more information the reader has to bring to the table, the harder it is to understand. A good narrative encapsulates all its necessary information. Similarly, a good method will reference as few global variables as possible. This not only reduces the struggle to understand the code, it also tends to increase efficiency and speed of execution.
The better fictions tend to introduce the main characters at the outset of the story. It’s jarring to meet the newest, most important character halfway through the climax. Follow the same pattern in your code - define all (or at least the most important) variables at the very beginning.
A good story doesn’t meander. A rambling story loses readers quickly. Rambling methods have the same effect - twice the length takes twice the time to understand and debug.
Some of this ties back to my thoughts on code texture.