Ping-Pong Pair Programming

Ping Pong (Pair) Programming is a programming methodology in which two pairing developers collaborate using TDD. Ping pong programming accentuates the benefits of test-driven-development. It can result in a very collaborative, but also competitive form of development - resulting in a game-like experience that gives minimal code with maximum function.

1 How-to

The “goal” of both developers is to have the most impact, while writing the least amount of code possible.

Let’s say Alice and Bob are pairing using ping-pong pair programming. Alice starts off by writing a failing test, as she would do if she were doing test-driven-development by herself. However, she doesn’t touch the implementation - instead she passes the keyboard to Bob, who will write the least amount of implementation that satisfies the test Alice just wrote. After that, he will write the next failing test himself and pass the keyboard back to Alice. She will implement only as much as is necessary for the test Bob wrote to pass. Then she will write a failing test again.

This can result in a competitive way of development, where Bob and Alice try to come up with the cleverest ways to get a good test, which will cover a lot of the implementation that still needs to be done, so that they don’t have to write that code.

2 Advantages / Benefits

2.1 Both developers need to understand the problem

With traditional pair programming, it can often be the case that only one of the developers actually understands the problem, while the other just joins in.

When doing ping pong pair programming, this isn’t possible, as both developers have to write tests (which require an understanding of the problem / requirements) and implementatin.

2.2 Game-like experience

It’s a lot of fun for both developers, as they are feeling like they are playing a game.

2.3 It results in very efficient code

Not necessarily in terms of performance, but the code will only satisfy what the tests are actually testing. This is even more extreme than if it was a solo-developer doing TDD, as it is very tempting to just continue implementing more complex logic for which there isn’t a test yet when working solo, as the mind tends to already go further.

When doing ping-pong programming, it’s the goal of both developers to write as little code as possible on each iteration, which means no-one gets ahead of themselves. It’s much more interesting to try getting the other to implement whatever it is you want implemented.

2.4 It results in a very good test-suite

Since the developers are lazy when writing the implementation, the tests need to be clever and cover as many cases as possible to force the other developer to write more implementation logic. That in turn leads to very thorough tests.

3 Resources

4 Backlinks   backlinks