Pseudocode Programming: fake it before you make it

I’m interested in exploring ways to write better code. Ways of organising your workflow or your thoughts that are more advanced than ‘write down the first thing that comes into your head’. Techniques that will help to produce clean, reliable and fault-tolerant code, or at least help you to arrive at the same conclusion you would have anyway but more efficiently.

Something that I learned about when skimming through Code Complete 2 by Steve McConnell is the Pseudocode Programming Process. He seems to have been the one who invented it as I can’t find references to it outside of this context.

The idea is a simple one: before you start writing code, plan what you will do in pseudocode first. It’s very similar to what you would do in a whiteboarding interview, except without the sweaty anxiety of having to perform in front of a group of strangers.

The theory is that any kind of design process starts off with a bunch of preparatory work. You start off with drafts, wireframes or maquettes and iterate on these, front-loading your exploratory work while making mistakes is cheap. You don’t think about touching your final medium until you have most of the fundamentals worked out. This applies to building a bridge, making a painting, writing a book, or coding some software. That’s the idea, anyway.

McConnell goes into a lot more detail than that, which I’ve heavily summarised below.

The Pseudocode Programming Process, in brief

First: define your prerequisites

This is your pre-pseudocode preparatory work. You should consider:

Next: design the routine in pseudocode

Now you can make your wireframe. During this stage you must resist the temptation, however hard it is, to write any code. You will really want to, but do not start writing any real code. The idea here is to get a high-level framework in place. If you start writing code, you are going to start worrying prematurely about implementation details. Instead you should:

Finally: write real code

The time has come to write real code! What a relief.

Trying it out

I experimentally used PPP last quarter to see if it would help me to write better code. Here’s some of my thoughts about it:

In summary

PPP feels like a useful addition to my tool box, but I’m on the fence as to whether it’ll end up staying there long term. I’m going to try it out on more complicated projects and see where it takes me.

For more analysis and opinion about PPP, there’s loads of interesting comments at the end of this article.