Writing Code Is Expensive- Avoid It.
Coding is one of the least efficient ways to discover solutions.
Today I learnt a lesson I already knew: Writing code is pretty much the most expensive way for me to be productive- I should therefore avoid it at all costs. It’s a hard lesson to learn, especially because writing code is so damn enjoyable- but it’s one that’s worth driving home.
Having defined my problem-of-the-day, I set out and wrote some code to solve it. By the end of the day, only a fraction of the original functionality remained. As my prototypical declarations began to be commented out, and then removed- it began to dawn on me that I’d once again used coding not just for the implementation of my solution, but as the route to discovering it also.
I trained as a civil engineer- I designed bridges. When you’re engineering a bridge, building it is very much the most expensive thing you can do. So much so that the notion of just rocking up at the river and iterating your way across, leaving behind the rubble of a hundred old attempts, is a ludicrous one.
Code, comparatively, is cheap. And that makes it very tempting to lose the engineering discipline. Today I solve the problem by ‘coding my way across the river’; trusting on instinct and experience to guide me in the right general direction, and shamelessly knocking down my old attempts when they started to get rickety.
My mistake wasn’t my inability to grasp the shape of the final solution before I started; I’d be dubious of any developer that said they could do this. No, it was my lack of discipline- I was discovering the solution in code. And while it may be cheaper than building bridges, it’s still one of the most expensive things I can do.
I have a big A3 scratch pad on my desk, and a worrying large collection of coloured fountain pens. The indecipherable scribbles, bewildering statements and pseudo-mathematical expressions all lay testament to the times when I’ve got it right:
Sketching out the problem and solving it in a space abstract from the confines and inefficiencies of ‘working’ code.
Iterating through thought experiments and trialing out ideas by examining them in theory; only stopping to prototype when the exploratory works demand it. This is how to develop cheaply; how to do for a penny what any dev can do for a pound. It’s only at the end that you need finally build it into code.
But today I needed reminding of that lesson. Blame it on the monthly work-social hangover.