Skip to content

Latest commit

 

History

History
146 lines (105 loc) · 6.71 KB

File metadata and controls

146 lines (105 loc) · 6.71 KB

How to Pair Program

Week 1 Keywords and Questions

  • Driver
  • Navigator
  • What is something you need to keep in mind when pair programming?

Prerequisites

Motivation

Pair programming is a very common way to write code and solve software engineering problems. Pair programming generally produces higher-quality code, meaning fewer bugs and better readability.

"If you don’t like pairing, don’t pair. But be prepared for the folks who have developed the pairing skill to fly past you."

  • "Uncle" Bob Martin

Which companies use pair programming?

Objectives

Participants will be able to:

  • Explain why pair programming is useful
  • Show how to drive and navigate
  • Demonstrate how to be a good pair partner
  • Outline potential challenges

Specific Things to Learn

  • What pair programming is
  • Why pair programming is useful
  • How to drive and how to navigate
  • How to be a good pair partner

Lesson

Pair Programming Across Varied Mastery Levels

As a new developer, you will have times when you will pair program with more experienced or specialized colleagues. This is an opportunity to rapidly accelerate your learning and grasp complex technical domains. This collaboration fosters immediate knowledge transfer, significantly enhances skill development, and improves code quality through real-time feedback. Ultimately, it strengthens team cohesion and cultivates a shared understanding of the codebase, leading to more effective problem-solving.

👩🏽‍💻 Session Management

  • Set clear goals before starting
  • Establish regular check-in points
  • Document insights and decisions
  • Define driver (writes) / navigator (guides) roles

🗣️ Communication Guidelines

  • Encourage questioning without fear
  • Maintain constructive dialogue
  • Focus on understanding rather than solutions
  • Define & document your agreed upon approach
  • Both developers contribute actively to problem-solving

🍏 Guided Learning Exchange with Open-Ended Questions

  • Instead of saying "use filter()", ask:
    • "What array methods could we use here?"
    • "How would you handle empty arrays?"
    • "What edge cases should we consider?"

🧠 Shared Problem Analysis

  • Confirm understanding of the problem and state assumptions
  • Understand core development considerations with questions:
    • "What are the key considerations for handling edge cases?"
    • "How would you test this function?"
    • "What performance implications should we consider?"
  • Discuss tradeoffs and/or benefits of your intended solution
  • Take a stab at understanding the complexity of the problem

🤔 Mutual Code Exploration Through Curiosity

  • While navigating: "Why did you choose this array method?"
  • During implementation: "How would you refactor this to improve readability?"
  • When encountering issues: "What debugging strategies would you recommend?"

⚙️ Implementation

  • Write code together
  • Test Assumptions
  • Document reasoning

Activity

Choose a prompt, find a partner, and practice the steps you've learned together.

/*
Prompt 1:
Given an input string, reverse the string word by word, the first word will be the last, and so on.
    reverseWords(" the sky is blue") ➞ "blue is sky the"
    reverseWords("hello   world!  ") ➞ "world! hello"
    reverseWords("a good example") ➞ "example good a"
*/

/*
Prompt 2: 
Write a function that takes an array of strings as input and returns a new array where the first element is moved to
the end of the array. You must use both shift and push methods to achieve this.
*/

/*
Prompt 3: 
Write a function that takes an array of numbers as input and returns a new array where the last element is moved to
the beginning of the array. You must use both pop and unshift methods to achieve this.
*/

Common Mistakes / Misconceptions

  • "I could be doing this so much faster on my own." Sometimes, this is true. But a big drawback to coding on your own is that you're far less likely to catch bugs early on. And, since no one is checking your code, the readability of code you write alone may not be as good as the readability of code you write with someone else. So while you may be able to write code more quickly by yourself, the time it takes to work through bugs on your own usually negates this advantage.
  • "Real programmers do not program in pairs." Some companies exclusively use pair programming (Pivotal Labs is one such example). Many companies use pair programming only at certain times or in certain situations. Some companies don't practice pair programming at all.
  • "I don't know what's going on or what my pair is doing, so I'm just going to sit back and watch them." Pair programming is not pair programming when only one person is doing the work. Speak up and advocate for yourself. Ask questions and stay involved! If you need a break to reset your mind, ask for one.

Additional Resources

Check for Understanding

  • What is pair programming?
  • What are the benefits of pair programming?
  • What does each person in a pair do while pair programming?
  • What should you do if your partner's pace is very different?