Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Flow is a concept introduced by Mihaly Csikszentmihalyi; in short, it means to get into the "zone". You feel immersed in your task, focused; the task can be difficult but challenging at the same time. When people achieve flow their productivity shoots up. Programming requires a great deal of mental focus because we often need to juggle several things in our minds at once. Many like to work in a quiet environment where they can direct their full attention to the task. If they are interrupted, it may take several minutes or even hours to get back into flow.

I understand there's a practice in agile development and extreme programming called pair programming. It means you put the whole software development team in one room so that communication is seamless. You do write code with your pair because this way you get instant code reviews and fewer bugs get through.

I've always had problems achieving flow while doing pair programming because of constant interruptions. I'm thinking deep about an issue then all of sudden someone asks me a question from another pair. My train of thought is lost.

How can you achieve and maintain flow while pair programming?

share|improve this question
4  
I don't agree that other pairs can just interupt at any time. –  JeffO Nov 18 '11 at 4:07
1  
An alternative to Flow is to identify and maintain position at the Ballmer Peak. This may take a good amount of experimentation, time, and Scotch to achieve. –  Hovercraft Full Of Eels Nov 18 '11 at 21:33

4 Answers 4

Edit: Disclaimer - This is how I define "the zone": A state of extreme focus, in which one is able to understand how many intricate details connect together, regardless of whether these do so elegantly (or simply) or not.

I try to avoid this state because, while I may produce correct code in the zone, I and other developers will have a hard time understanding it later on. To put it short: reading code that was written in the zone may often require the reader being in the zone. That constraint is my problem.

There's a lovely chapter on The Clean Coder where Uncle Bob persuasively explains why "getting into the zone" is a delusively bad idea.

Here's a possibly better alternative than "getting in the zone": think straight and consider calmly and professionally what you're doing. Communicate. Share thoughts with your partner(s). Identify the real problems. Discuss possible solutions. You might not feel supernaturely focused, but you're likely to make good decisions, and approachable designs.

If you and your pair-partner can discuss the problem without both of you being extremely focused, then chances are you've boiled the problem down to its simpler nature. That suggests you'll be able to understand it again whenever you need to.

On the flip side... If you just need some time alone to get your head straight (we all do sometimes), just take it. Get your thoughts together. Work the problem out in your head first.

But the thing is that if you do - don't use that time to write production code. Instead, play around with sample code and prototypes. Try to understand the problem, without thinking about solutions just yet. Once you get everything straight and written down, discuss it with your team and pair partner, or even the rubber duck on your desk. If you still can't articulate it, or they can't understand it, then refine your ideas. Once you've nailed all of that down - integrate all that thought and sample code into a real, working solution.

share|improve this answer
1  
I'd upvote a million times if I could, professionals learn to work whether they are "in the zone" or not. Professionals can work with peopleinterupting them to ask questions, with noise around them, and together with other people actually having conversations about how to do whatever task they are working on together. I'm not interested in working with prima donnas who have to have special working conditons to concentrate. –  HLGEM Nov 18 '11 at 21:24
    
Indeed. In my opinion, this "zone" attraction epidemic leads to a lot of wrong intuitive decisions - which lead to some of the things I try to avoid the most when I work. You can see my post for more details, if you're interested. –  Yam Marcovic Nov 18 '11 at 21:29
4  
@HLGEM - I don't think having access to a quite place to work when needed is too much to ask for. –  JeffO Nov 19 '11 at 11:36
    
@JeffO It depends on the nature of the job. In some jobs, it might just be too much to ask for. I guess some of us wouldn't fit in that kind of job, but that doesn't mean that because of that it can't exist. –  Yam Marcovic Nov 19 '11 at 12:02
2  
@HLGEM: Of course a professional is supposed to have average productivity under average working conditions. But on the other hand it would be in the employer interest to let the same professional work in a very focussed way, because this can enormously increase productivity and quality. –  Giorgio Mar 31 '13 at 17:18

Pair programming sometimes requires periods of isolation from your partner.

Example

You are working together on a particular class, and you realize that you need to write a method that requires deep thought on some complex logic, but otherwise returns a mundane result. You work together on creating unit tests for that method, and defer the writing of that method to a period of time when you're working in isolation. When the method is completed, you get back together as a pair and evaluate the results.

share|improve this answer

As a developer attempting to get into the zone, you'll attempt to isolate yourself as best as you can to get comfortable and clear your mind. Why should pair programming be any different?

You and your partner should find a zone-inducing environment that works for you both. This will possibly require compromise on some things, but my main point is that the pair environment should be similar to the solo. Turn off the external world. The pair is programming together; other pairs (other co-workers in general) should not be interrupting (excepting critical, drop-what-you-are-doing problems).

share|improve this answer

I've found there is a small class of problems for which pair programming works. For example, if you are working on a cross platform product and the Winders guy has implemented a feature that requires OS specific code, he can help the Mac guy implement the same feature on the Mac code while the Mac guy drives.

However in my experience pair programming unusually results in a net loss of productivity. It so often feels like we're paying two developers to do the job of one.

Yes, it reduces the horrifying possibility that a dev might take a stackexchange break during the workday.

IMHO it would be cheaper for those companies who want to police their devs to just pair every dev with a private security guard to stand behind the developer and hit the dev with a truncheon if he ever slows down or tries to peak at a non-essential web page.

share|improve this answer
    
+1: I wish I could upvote this 100 times. :-) –  Giorgio Mar 31 '13 at 17:20
    
The point of pair programming is not stopping each other from slacking off; that wouldn't even be effective. The point is having code review in real time. –  Lev Apr 2 '13 at 10:03
    
@Lev: Having a code review before committing is much more efficient: the review takes from a few minutes to half and hour, instead of an entire workday. –  Giorgio Dec 18 at 12:06
    
@Giorgio Not quite. For example, it can so happen that you make a bug, then waste time catching it, and only then get your code reviewed and commit. If you had pair programmed, your partner would have noticed the bug and saved the debugging time. –  Lev 2 hours ago
    
@Lev: "If you had pair programmed, your partner would have noticed the bug and saved the debugging time.": There is no guarantee that a bug is noticed either with pair programming or with code reviews. E.g., after six hours of pair programming one might be so tired that one easily overlooks bugs. –  Giorgio 15 mins ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.