Pair programming [http://c2.com/cgi/wiki?PairProgramming]  helps me keep focused. Two people talking about what they are doing, spotting bugs, discussing code – that’s what I love to do. Unfortunately, it is very hard to convince project managers that you are at least twice as efficient when working in a pair.
Doug: I know pair programming has been discussed extensively elsewhere. Since I know you and we’ve talked about coding a lot, I’ll go ahead and include my experiences here.
Here’s a practical example. I’ve been developing a Linux device driver for a USB device. I’ve had only minimal experience in the Linux kernel prior to this. It could be argued that my company should have hired someone else to do the work. For obvious reasons, I won’t go down that path. The device is fairly proprietary, but I had “full” vendor support. I quote that because the vendor wasn’t always available for direct comment even though they supplied me with all the docs I needed and encouraged me to write the driver. The total elapsed time for me to write the driver and call it “done” has been about eight months. Granted, I’ve been distracted on side projects and such. I’ve spent a lot of time trying to figure out kernel programming and the USB stack. I’ve gone down several dead-end paths and had to re-write significant amounts of code. All in all, though, my current code is very clean. It’s a lean 1500 lines of code that’s well written with lots of unit tests. The interesting thing is that about 30% of the code was written in two one-week sessions when I was pair programming with another engineer from the vendor’s company. This individual had extensive experience with MS-Windows device drivers and with the hardware itself, but none with Linux. I am very confident that the entire drive could have been written in three months if Stu and I had worked full-time together on it pair programming. That’s a minimum net savings of a couple months of salary and lots of months of scheduling. It’s likely that we could have done it faster than three months. Besides that, the code is much cleaner and better tested than if I hadn’t had his help. You might argue that we should have given the whole project to Stu and just paid him. Undoubtedly he would have gotten it done in less than 8 months. However, I’m also certain his code would not have been as good as the current code is. And, he probably wouldn’t have gotten it done as fast as the two of us working intensively together.