Pair programming

Practice writing code and getting support

Pair programming is working together with someone else to code a solution to a problem.

There are 2 main types of pair programming: Mentored and Driver/Navigator. At CYF you will use Mentored Pair Programming with volunteers, and you can do Driver/Navigator style when working with other trainees.

Why

Pair programming is an excellent way to develop programming and communication skills.

It can be easier to work through a problem when working with someone 1-to-1.

Pair programming prepares our trainees for technical interviews when they’ll code in front of other people.

How

You can do pair programming in person sharing one computer.

You can also do it remotely:

  • By sharing your screen using a slack huddle
  • Scheduling a google meet, or similar online meeting
  • Using a VS Code extension like CodeTogether or Live Share.

A trainee that wants to do pair programming should:

  • Visit the #cyf-pair-programming slack channel
  • Book a time using a mentor’s calendar
  • If you do lots of pair programming, try to book with different mentors to get more diverse help

A mentor that wants to do pair programming should:

  • Create a bookable calendar for 30 minute appointments, something like Google Calendar or Calendly works well
  • Share your calendar in the #cyf-pair-programming slack channel and canvas page (link at the top of the channel)
  • For your first pair programming, ask another mentor to shadow you on your first call to get feedback on your approach

Mentored Pair Programming

We assign mentored pair programming as a coursework assignment throughout the course. Each session should last between 30-60 minutes.

Before a mentored pair programming session, learners should decide what they’re going to pair on and share this with the volunteer, e.g. by sharing a link to a particular Codewars exercise, a particular piece of coursework, or some other problem.

During mentored pair programming, the learner should:

  • Explain their thought process
  • Break down the problem
  • Plan what code to write
  • Write all of the code
  • Check that it works

The mentor should:

  • Ask questions to get the trainee thinking. It’s always better to ask than tell.
  • Help the trainee think about breaking down the problem
  • Support the trainee if they encounter hurdles
  • Stretch the trainee by bringing up edge cases or complications

Tips for learners

When approaching a problem, you need to explain your thought process, plan out what to do, write the code, and check that it works.

If you jump in to writing code without explaining your thinking, it will be more difficult for the mentor to offer you help.

Tips for mentors

The goal is teaching: Rather than driver/navigator programming you may use in your work, where the goal is to produce code for a project, the goal of mentored pair programming is to teach a trainee how to become self sufficient when faced with a programming challenge. The ultimate goal of mentored pair programming is to get the trainee in a position where the next time they encounter a similar problem, they will be able to solve it better than they did this time.

Help people learn: Most of the exercises the trainees are doing aren’t useful in their own right. The point is for the trainee to learn and grow through them. Focus on understanding, and techniques that will help solve the next problem.

Don’t take over! It’s important trainees get used to figuring things out. Provide guidance and assistance but trainees need to struggle to overcome any obstacles with understanding and technical communication. It can be uncomfortable to watch someone struggle, but make sure they’ve considered and tried all of their ideas before you intervene.

Give honest feedback: Trainees can’t develop if they don’t receive honest feedback about their progress.

Ask questions! Asking a clarifying question can help learners discover errors and often promotes more thoughtful responses. Asking is better than telling. Asking questions also helps to avoid long silences, and it can help push a trainee who is stuck and doesn’t know how to proceed.

Encourage re-usable techniques: Reinforce techniques like reading error messages carefully, looking up documentation, and thinking about edge cases. You might feel tempted to search for something on your own screen, instead ask the trainee to do it and this will help them learn the right kind of things to search for if they get stuck.

Driver/Navigator Pair Programming

Driver/Navigator is a different model of pair programming. This is the style you would encounter in a workplace. As a CYF trainee you might find it useful when working in pairs on a project, or trying to get past a blocker. There is no single mentor offering support, instead you work together to solve a task.

It differs from the mentored style because both developers in the pair take turns coding:

  • One acts as the driver - using the keyboard to write code, following the navigator’s suggestions.
  • One acts as the navigator - providing a high level plan of what to implement, and reviewing what is typed.
  • You swap every 10 minutes.
  • After you have both had a go, take a 5 minute break.

You can do driver/navigator pair programming regardless of the levels of the pairs. Lots of people do this at work as software engineers. This is not just a learning tool, it is used to make professional code.

You may find these links helpful if you want to learn more about the Driver/Navigator style: