If you’ve done any mind intensive task, even taking a very challenging but doable exam, you probably understand the concept of “flow”. Flow (aka getting “in the zone”) happens when you are hyper-focused on a particular problem or task, and you are able to provide contiguous output on the problem, pretty much non-stop.
Personally, coffee helps me get in the flow a lot. If I have some audio distractions around me, then Trance music can help too (preferably very repetitive and with no words). I know some people who compare the feeling of this “flow” to what happens when you’re on Adderall. The rest of the world and the seconds that it ticks with just disappear, and as a programmer, your fingers never stop typing.
It’s an amazing feeling, and I have within the past month read two different authoritative reviews on how it really affects your productivity. According to Robert C Martin in The Clean Coder, flow is patently bad. He compares it to being hypnotized (I’m not arguing there), but he says code produced in the flow is code that is unaware of the bigger picture, and not flexible. A lot of code produced in this way has to be revisited and re-architected at a later date because it will be single-minded and not jive with the rest of the program.
Just today, I read one of the old Joel on Software posts by Joel Spolsky entitled “Where do These People Get Their (Unoriginal) Ideas?” where he says that achieving flow is one of the basic requirements of programming in general as focusing on the problem very closely helps you solve it quickly and more thoroughly.
What are your experiences with this?
Personally, I fall more on Joel’s side, but with some reservations. You need to make sure you have your environment set up correctly and you know proper programming standards. My most solid code has been written in the flow while following TDD. I was able to easily refactor it for later additions and it was solid, usable and well documented (I write all of my PHP code with PHPDoc / JavaDoc style comments). Putting all of these together and still focusing hard on the problem gives me excellent progress while still generating maintainable code.