Pair Programming
"Pair programming is a style of programming in which two programmers work side-by-side at one computer, continuously collaborating on the same design, algorithm, code, or test." ... "based on a survey (Williams 1999) of pair programmers " .. " 100% agreed that they had more confidence in their solution when pair programming than when they program alone. Likewise, 96% agreed that they enjoy their job more than when programming alone."
| All I Really Need to Know about Pair Programming I Learned in Kindergarten
Benefits
How To Pair Program
- Pair programming is a skill itself. Here are a few quotes from All I Really Need to Know about Pair Programming I Learned in Kindergartenwhich give tips to be a successful pair programmer
- "With pair programming, one person "drives" (has control of the keyboard) while the other is continuously reviewing the work. Even when one programmer is significantly more experienced than the other, it is important to take turns "driving""
- "When one partner is busy typing, the other is thinking at a more strategic level - where is this line of development going? Will it run into a dead end? Is there a better overall strategy?"
- Ego-less programming
- "First, having a "my way or the highway" attitude can prevent the programmer from considering others ideas. Secondly, excess ego can cause a programmer to be defensive when receiving criticism " ... "Conversely, a person who always agrees with their partner lest create tension also minimizes the benefits of collaborative work."
- "Making the transition to pair programming involves breaking down some personal barriers " ... "First the programmer must understand that the benefits of intercommunication outweigh their innate preference for working alone and undisturbed. Secondly, they must confidently share their work, accepting instruction and suggestions for improvement in order to improve their own skills and the product at hand. They must display humility in understanding that they are not infallible and that their partner has the ability to make improvements in what they do. Lastly, a pair programmer must accept ownership of their partner's work, and therefore be willing to constructively express criticism and suggested improvements."
A Pair Programming Session
- 2-3 hours of highly focused, uninterruptible work.
- Both people should take turns at the keyboard during each session.
- Do not pair program in someones cube! Always use a shared environment where everyone is equal.
- Only 1 computer should be utilized to avoid the tendency of splitting off and working side-by-side.
Pair Programming Projects
- I think most pair programming projects will fall into 1 of these 4 buckets. If you are looking for something to do during your pair programming session, go through these in order to find a project.
- New Feature
- If a new feature is needed for a project, instead of assigning one person as primarily responsible, assign two. When two people are responsible we get all the benefits of collective code ownership. People’s mindsets will move from “John Doe really messed up feature X” to “We really messed up feature X.” Or even better, “We have a great design for feature X and completed it in only 1 hour”.
- Refactoring / Bug Fixing
- Refactoring code is a common exercise. It is typically initiated when a bug is found, requirements change, or “broken windows” are found in code (ie. bad code See the Pragmatic Programmer's No Broken Windows theory.
- Refactoring is a great thing to do in pairs, as frequently the pair will be refactoring code that one of them wrote independently. This will give the other person a chance to get to know the code and to give suggestions on improvement. If refactoring is occurring because of a "broken window", the person who wrote the code may be able to learn something from the exercise.
- Test Creation
- If you don't have a new feature or refactoring to do, write tests! More tests are always needed and anyone can write them.
- Non Programming Project
- The concept of pair programming can carry over to non-coding activities.