Whether it’s an essay or a program, writing is not about what you put out, it’s about what you take in. The purpose of life is to learn, and that is why writing is important.
I don’t follow this process with everything, because it’s a bit slow. But for complicated subjects, it’s sometimes the only way to get something useful.
Step 1: Sketch
Write as quickly as possible, as dirty as necessary, giving no thought whatsoever to the quality of the output. Just get it out of your head and into the real medium. Make the code run. Put sentences on the page. Don’t worry if it’s ugly or slow or badly worded or whatever. That’s the point. Just the act of getting it out of your head is important and necessary.
Step 2: Discard and Rewrite
Don’t revise your rough draft. Throw it away. Maybe it had some good parts, fine. You can look at them, but you’re not allowed to copy and paste anything. Type it out again. You want it to filter through your brain and your hands so that every character is re-evaluated.
Go slow here. The goal is to make it as elegant as possible, to really carefully consider each part’s relationship to the whole, to enforce balance and symmetry and consistency of intent. This is where the vision takes shape.
The goal isn’t to end up with something clever. It’s to end up with something obvious. The solution should simply seem to grow out of the problem and attach to it, like its natural symbiotic twin. Reading your program or your essay should be easy, and should leave a reader with the understanding that you gained in your sketching and meditation.
Occasionally, you’ll learn something, and have to return to step 1. And that’s great.
Step 3: Test with Absurd Aggression
If it’s code, then find or write a test suite that goes over an absurd amount of edge cases. Try really hard to make your program break. And then make it pass every single test case. Write some more test cases to cover areas that the suite doesn’t.
If it’s text, then read it over and over. Scrutinize every word to make sure it means exactly what you want. Go to bed and wake up and read it again. Have other people read it and push them to be really critical. Ask them what they thought, and make notes of where it’s different from your intent.
Return to step 2 as necessary.
Step 4: Optimize
We always want to put this step earlier in the process, but that’s almost always a mistake. Certainly, you don’t want to be structuring your code in ways that are always going to be slow, but if you’re writing for elegance, that’s not likely to happen anyhow.
Profile your program, and find the parts of it that are slow. Make them fast, even if you lose a bit of beauty in the process.
If it’s an essay, try to remove everything that does not enforce the thesis. Any word that can be removed should be.
Keep returning to step 3 after any changes.
It’s never done. You just reach a point where you decide to study something different.