Saturday, 4 December 2010

Hammock Driven Development

I would love to be able to claim credit for that phrase. But I can't. It's actually the title of a talk that Rich Hickey gave at the first Clojure Conj in which he 'rants' about the importance of really thinking about problems. These are my notes on the talk.

It's all very well having methodologies and processes for developing great software. But it's even more important to really understand the problem you are trying to solve. Bugs discovered in production are more expensive to fix than bugs discovered in the development phase. The less code that exists, the easier it is to fix problems. By extension, it's easiest to fix problems when no code exists at all. Time spent critically thinking about potential solutions enables you to identify errors that, if unresolved, would ultimately lead to bugs in the code.

"Most of the biggest problems in software are problems of misconception."

So what do you do?
  1. State the problem. Say it out loud or write it down. You need to be clear about what problem you are trying to solve. And if you are not trying to solve a problem then what exactly are you doing?
  2. Understand the problem. Read around it. Are there related problems? What don't you know? What questions do you have?
Not everything is awesome. Look for problems in your own solutions. Look for problems in the solutions proposed by others. By constantly challenging the solution you can refine it and improve it.

So where does the hammock come into this? Well, Mr. Hickey contrasts what he calls the waking mind and the background mind. The waking mind is good at analysing, finding problems, and identifying 'local maxima' - polishing an idea until it shines. The background mind makes the giant leaps of intuition to generate completely different ideas. The key is to utilize both aspects of the mind.

When you have a problem to solve, use the waking mind to provide the background mind with data. Read around the problem, think about it, draw pictures, write a song, whatever. Use your waking mind to cram as much information as you can find about the problem into your head.

The next step is to hit the hammock. Take some time to lie down, close your eyes, and think. Rich refers to this as "mind's eye time". The important thing is to step away from the computer, and away from all distractions. You need time to process all the input, to think about it and analyse it from as many angles as you can come up with.

The time spent on the hammock is time spent reinforcing everything that you have input. Then you hand over to the background mind to let it come up with the solution. It probably won't be instantaneous. You should at least expect to wait overnight, and it may even take months. But eventually, Deep Thought will speak. Probably while you're in the shower.

I always enjoy watching videos of Rich Hickey speaking. He comes across as someone who knows his subject inside out. Having watched this particular video I now understand why. He clearly thinks very deeply about the problems he is trying to solve. This is something that I would like to emulate.

Now I'm going to go find a hammock to think this over some more.