CS 70

Pair Programming

CS 70 uses the pair-programming methodology for all homework assignments (excluding proficiency checks, which are a separate category). All homework will be done as a pair, with one joint solution turned in by that pair.

In the pair-programming model, you must spend the bulk of your time working together as a team on a single piece of code, with one person typing and the other watching and making suggestions. All work of your work must be a joint effort—you will be violating the honor code if you work separately with one person doing some of the work and the other person doing the other part.

You’ll pair up three times over the course of the semester, so be ready to make friends with other students. Each pairing works for about a third of the semester and does about a third of the assignments. You are free to choose your own partner, or you can elect to have us assign you a partner. In most cases you must have a new partner for each group of assignments.

Rules

Normally, pair programming is done literally side-by-side or face-to-face, with both coders sharing a single computer. We hope that you can mostly work in that mode. However, as we continue to navigate the ongoing pandemic, we will permit you to pair program remotely if doing so is the safest option.

Here are some rules:

  • When pair-programming, sit side-by-side at one screen, face-to-face in the lab, or use VSCode Live Share so that you can both see and type code on a single machine.
    • If you can't get Live Share working, get help ASAP! In the meantime, you could use screen sharing as a backup position (Zoom even lets you share control of your keyboard and mouse), but ideally only as a short-term workaround. Do not settle into screen sharing as a long-term solution unless there is truly no other option.
  • If you need to pair-program remotely, use video chat so you can talk to each other and see each other's faces.
    • You can use whatever tool makes sense for you as long as you can send a link to someone else (like a professor or grutor) to invite them into your call when you ask for help. Live Share's built-in chat, Zoom, and Google Meet are all good choices.
    • If technical limitations (e.g., bandwidth constraints) make video impractical, you can back off to voice chat or a phone call. If these issues are frequently the case for your pair, please reach out to us so we can brainstorm possible workarounds.
  • At any given moment, one person has responsibility for the keyboard and is known as the driver. The other person is observing and is known as the navigator.
    • The driver and navigator collaborate on all aspects of software development: design, coding, debugging, and so on.
    • The driver does the actual typing of the code.
    • The navigator is thinking about broader issues, such as
      • How does our current code fit into the larger picture?
      • How will we test our code to see if it works?
      • Is there an assert statement we could write for this function?
      • What should we do next? Are we making any discoveries that require changes to code we've already written?
    • The navigator also observes the code being written and checks it for defects, but the primary role of the navigator is not just to say, “Oh, I think you're missing a semicolon there,” or provide similarly trivial feedback. The navigator's job is to steer the software development in the right direction.
    • Periodically, the driver and navigator change roles. Swapping roles is a crucial part of pair programming—you are each required to spend roughly equal amounts of time driving and navigating. You should generally aim to switch roles every 30 minutes or less.

Honor Code

The honor code applies to pair programming as it applies to everything else you do in CS 70. Specifically, pair programmers must

  • Produce all code in collaboration;
  • Contribute equally, including spending equal times driving and navigating; and,
  • Promptly report any violations of the rules, whether specifically related to pair programming or not.

Exceptions: What You Can Do Alone

Before you meet together, you can and should read over the assignment. Print it out. Make notes on it. Highlight important parts. (The assignments in CS 70 can be complicated, so marking them up yourself can be very helpful.)

Similarly, you are always free to mull the assignment over in your head. You can think about your algorithms and how they could work better, and, if you have a bug, you can think about how to solve it. You may also reread the code the two of you have written when you are alone, but you usually cannot change it without your partner present.

Finally, you may, sometimes, fix some very tiny bugs. Specifically, if you discover a “Duh!”—style bug (e.g., forgetting to initialize something), you may fix it, if and only if

  • The fix is “trivial”; and
  • You check in the code with your fix immediately and email your partner to alert them to the change.

You may not make substantial or nontrivial changes to the code by yourself. This prohibition includes “cleaning up” the code.

Why Pair Programming Works

It's easy to see the benefits of the pair-programming approach. You've probably experienced times when just “bouncing your idea off someone” has been very enlightening and very helpful. Just explaining your solution to someone else will help you clarify what you think you're doing and helps you catch any pitfalls with your approach. Add to those advantages the fact that your partner will chime in with ideas of their own, and you can see that the power of two is much greater than the power of one.

Another great benefit often surfaces when you are working on some new aspect of programming. A common occurrence is simply getting stuck—that is, you arrive at some point where you don’t know how to proceed or where your code is not working for reasons that are unclear. Sticking points like these can easily frustrate you for a few hours or even a few days.

But with a partner to help you, in many cases you will find that where you are stuck, your partner will know the answer, and vice versa. Almost everyone who tries pair programming reports that that there is far less “down time” (and the frustration it causes) due to programming difficulties.

Pair programming will also help you learn more. When your partner explains something to you, you learn something new. When you explain something to your partner, you understand it better. When you both figure something out together, you both learn it, and in less time than if you were working on your own. Mutual tutoring and problem solving is truly a win–win situation.

What Pair Programming Is Not

Be sure you understand that pair programming does not mean dividing the assignment into parts and each of you doing one part. That approach is a common one, but it's not pair programming and does not provide you with the benefits outlined above.

To reiterate: In pair programming, all the work is done with both team members working on the same code, on one machine, at the same time.

How to Succeed

There are only a few requirements for a successful pair-programming project. First, the partners must be compatible. Working with a friend is a really good idea; working with someone you don’t like or normally disagree with is not.

Another key ingredient is having compatible schedules. Because you have to work at the same time, you both have to be available at those times. When forming a pair, be sure to discuss your schedules and be certain that you will have adequate opportunities for working together.

A final consideration is skill levels. In any class, different students will have different amounts of programming experience and skill. Pair programming will work for you no matter where you are in that range, but it will work best if both partners are at about the same skill level.

Tips for Good Pair Programming

  • Respect your partner. If you say you’ll meet at a particular time, be there on time. Know each others' cell-phone numbers so that you can call or text if something’s up.
  • Agree clearly on what each of you will have done before you meet. Time working together is precious, so use it well, and meet the commitments you make to each other.
  • Stay fairly close to 50—50 on driving and navigating. Let the less-experienced partner start and maybe drive a little more.
  • Make sure your partner stays focused and on-task.
    • For yourself, try to create a quiet and comfortable workspace where you can focus. Clear your screen of distractions while you are working.
  • Keep your feedback positive. Coding together is an opportunity for both of you to improve your skills.
  • Don’t take things too seriously. If your partner picks out a bunch of errors as you type, be glad. But you don't always have to agree with them. If you have a different opinion about some issue, you can (and should!) talk about it. Finding a good balance will require you to meet each other halfway.
  • Don't start off by being skeptical about pair programming or your partner's abilities. Buying in to the process and “jelling” can lead to a whole that is greater than the sum of the parts.

Benefits of Pair Programming

  • When one person gets stuck, the second can often get them “unstuck”.
  • When both people get stuck, they spend less time struggling and seek help sooner.
  • Your software will be cleaner, better organized, and have fewer bugs.
  • You will learn more of the basic concepts that the assignment is designed to teach.
  • Your exam performance will be about the same as if you had worked on your own.

(When logged in, completion status appears here.)