I spend most of my time reading and modifying code, only a small portion of it writing code from scratch. When I break ground on new code, I spend quite a bit of time trying to reason about how understandable it's structure will be to future programmers (myself included!).
I feel a program should read like a story - line by line it should tell you what the program is going to do when it runs. The closer I can bring my code into being a linear set of steps that I can follow from top to bottom, the easier it will be for me to grok in the future.
Take this trivial function for example:
async function loadConfig() {
const [ error, config ] = await readYaml('./config')
// If we didn't run into an error, try parsing the config
if(!error) {
// Parse wibbles
for(let i = 0; i < config.wibbles.length; i++) {
// Is the wibble a wobble?
if (isWobble(config.wibbles[i])) {
config.wibbles[i] = parseWobble(config.wibbles[i]);
// Is the wibble a ruble?
[...truncated...](/file/early-returns)