Slides
Pair Programming
Pair programming =
Two people +
One problem
(and usually, one computer, one keyboard, one screen...
...notwithstanding remote pairing tools and face-to-face pairing desks)
Pairing is like Rally Racing
One driver, one navigator
Listen to how engaged the navigator is. They are focused on what's coming next, but they are not idly speculating. E.g. circa 4min in
Pair Programming Benefits
Two heads are better than one!
- avoid dead ends and ratholes
- simultaneously focus on current problem and context (one focus per person)
- "rubber duck" - explaining a problem out loud often leads directly to a solution
- instant code review
- exploit complementary expertise / memory / personality / energy levels
- less likely to fall into bad habits or get stuck
Pair Programming finds the Maximum of Two Minds
[show graph of maxima]
Every person thinks a little differently, has different expertise / experience / energy / perspective.
So for any given problem, at any given moment, one of the partners will be more able to solve that problem.
With pair programming, you get the best of two at every moment.
(And often you get solutions that are better than any individual would have come up with alone.)
Pairing is efficient
MYTH: pairing reduces productivity by 50%
FACT: pairing (when done well) increases productivity, especially when the problem requires creativity to solve
(pairing also increases communication, satisfaction, and the rate of high-fives per minute)
Pairing is teaching
Docendo discimus - "by teaching we learn"
- Expert-expert pairing -- best case; experts share tidbits and experience as peers
- Novice-novice pairing -- good case; novices can struggle and discover together
- Expert-novice pairing -- beware -- in this case, the expert must accept the role of mentor or teacher, and be patient and let the novice drive most of the time
Roles
- Driver
- Navigator
Driver
- writes code, runs tests, has control of code
- focuses on one problem at a time
- self-narrates at a high level
- e.g. "Okay, now let's introduce a random number function"
- NOT "I'm now creating a variable named X that I'm assigning the value 4"
- assume your navigator can read the code and understand it; the goal is to communicate purpose and intention, not mechanics
Navigator
- keeps a "todo" list
- politely reminds driver, e.g.
- can we write a test for that?
- can we refactor a bit now?
- let's check in
- let's revert
- let's take a break
-
always asks permission before grabbing the keyboard
- "do you mind if I drive now?"
- silently count to 10 before interrupting with e.g. a typo or syntax error
- chances are that the driver will notice and fix it themselves
Tag Team
Switch roles often!
- at least once per hour, preferably more frequently
- pomodoro technique can help -- code for 25 min, then take a 5 min break, then switch drivers
Ping Pong
- Alice and Bob are pairing
- Alice writes a unit test and gets it to fail correctly
- Alice hands the keyboard to Bob
- Bob writes code until the unit test passes ("goes green")
- Bob writes a unit test and gets it to fail correctly
- Bob hands the keyboard to Alice
- Alice writes code until the unit test passes ("goes green")
- Repeat until done!
Breath Mints
It's better to have them and not need them, than to need them and not have them.
Do...
- Talk. A lot.
- Ask questions.
- Listen.
- Say something if you don't understand or disagree.
- Be patient.
- Swap roles often.
- at least every 30 minutes
- Take breaks regularly.
- at least once an hour
- High five!
- Enjoy it!
Don't...
- get too frustrated
- be a keyboard hog
- be a backseat driver (instead, ask to take the wheel!)
- be bossy
- be intimidated by partner's knowledge
- be shy
- be silent
- about your ideas / questions
- about your partner being rude
References
Videos:
- Fiona and Semira from Generation Code: https://www.youtube.com/watch?v=vgkahOzFH2Q
- Steven Nunez from Flatiron School: https://www.youtube.com/watch?v=YhV4TaZaB84
- Laurie Williams from North Carolina State University: https://www.youtube.com/watch?v=rG_U12uqRhE
Articles:
https://www.wikihow.com/Pair-Program
https://pdfs.semanticscholar.org/a7b9/eaf874127108f131cb05f8f513c10b5f00d1.pdf