2008-02-22

Holding a Program in One's Head

Wow! And especially so since I just finished listening to a Scott Hanselman Computer Zen podcast with Dr Michio Kaku on how theoretical physicists think and work - visualizing their problem spaces in their heads ... because the problems they're working on can't be expressed, stored or solved on computers. So, yeah, wow! In any case, more from Paul Graham:

A good programmer working intensively on his own code can hold it in his mind the way a mathematician holds a problem he's working on. Mathematicians don't answer questions by working them out on paper the way schoolchildren are taught to. They do more in their heads: they try to understand a problem space well enough that they can walk around it the way you can walk around the memory of the house you grew up in. At its best programming is the same. You hold the whole program in your head, and you can manipulate it at will.

...

Your code is your understanding of the problem you're exploring. So it's only when you have your code in your head that you really understand the problem.

It's not easy to get a program into your head. If you leave a project for a few months, it can take days to really understand it again when you return to it. Even when you're actively working on a program it can take half an hour to load into your head when you start work each day. And that's in the best case. Ordinary programmers working in typical office conditions never enter this mode. Or to put it more dramatically, ordinary programmers working in typical office conditions never really understand the problems they're solving.

Even the best programmers don't always have the whole program they're working on loaded into their heads. But there are things you can do to help:

  1. Avoid distractions
  2. Work in long stretches
  3. Use succinct languages
  4. Keep rewriting your program
  5. Write readable code
  6. Work in small groups
  7. Don't have multiple people editing the same piece of code
  8. Start small

No comments: