A very common piece of programming wisdom that gets passed around is to think before you code. My favorite expression of this idea is “Weeks of programming can save you hours of planning”. That being said, not all thinking/planning is equal. In this post, I share a creative writing technique I’ve put into practice to great effect at work; freewriting.
The idea is simple; you write down your thoughts as they arise. Forget about editing. Forget about grammar. Just write down a stream of consciousness. I prefer to use pen and paper for this, but I find the practice equally effective at the computer. I usually start each exercise with a sentence like “I don’t know what to do for this thing”, then go into detail about the problem, as well as any solutions that crop up and their respective tradeoffs. After a while, I find that as the words fill the page, my mind becomes more focused on the problem. More often than not, I come up with an effective solution to the problem I describe toward the beginning of the stream.
I’ve started freewriting whenever I feel stifled at home or at work. I find it to be a great way to break away from the computer while still thinking deeply about programming. In addition, I relish every opportunity to write with my fountain pens.
One reason why I think the technique is so effective is that you quickly begin using System 2 (borrowing Daniel Kahneman’s terminology) to digest the task at hand. Furthermore, by writing down your thoughts, you make yourself more resilient to distractions. Suppose someone comes by and ask you a question. If you’ve been writing down your thoughts, you can simply re-read what you’ve written in order to recover your train of thought. This can avoid situations like this (credit to Jason Heeris).
For your viewing pleasure, here (830KB) is a photo of one of my sessions. TL;DR: I’ve been wrestling with how to write a a good API for a set of NIFs I’m writing for a fast metrics library. In the end, I decided it’s a better idea to focus on implementing static configuration and putting machinery in place to allow for property testing.