TrainingConferencesAbout UsContact UsAdvertiseSQE.com

StickyMinds.com: brain food for building better software

Join

Join

Clarify Your Search Criteria
Tips on Using Our Search Feature(s)
StickyMinds.com Home
ResourcesEventsTopicsPowerPassJobs
Software Testing & QA Online Community  >  Detail: Ping-Pong Programming


A StickyMinds.com Original
Article Picture
Ping-Pong Programming

By Dave Hoover

Send This Content to a FriendGet a Short Link to This ContentPrint This ContentSee User Comments About This Content

Summary: Team player Dave Hoover wants to share a software development practice he enjoys. It emerged from the practices of extreme programming as a competitive yet simultaneously collaborative practice. Dave has found that this practice promotes the flow of knowledge between software developers better than any other practice he has experienced. As you might have guessed from the title of this week's column, this practice is called ping-pong programming, or P3 for short.


ASTQB
Ping-pong programming (P3) is an offspring of two well-known extreme programming practices: pair programming and test-driven development. These practices by themselves promote intra-team knowledge sharing. But this is extreme programming, and we like to push the envelope, right?

I experienced a precursor to P3 when I visited Object Mentor in 2002. I was attending their Java Language Immersion and I was the only student of Micah Martin for the entire week. We had a great time. As we began working through the payroll exercise, Micah started by writing a test and sliding the keyboard over to me. I then tried to make it pass. At first, I took giant leaps ahead of him, coding far more than it took to get to a green bar. He patiently watched me as I stumbled around, often getting lost down rabbit holes. Periodically, he drove for a moment, doing something absurdly simple to get the test to pass.

I started getting a feel for how easy it was to take small steps. And I started to enjoy taking as small a step as possible, which led Micah to write more rigorous tests. This felt like a great way to combine pair programming with test-driven development. I took the technique back to work with me and immediately tried it on my XP pilot project. It was met with mixed reviews. Some programmers resisted the idea that they would be writing tests while someone else did all the coding.

Fast forward to the summer of 2004: my first project at ThoughtWorks.

Aslak Hellesoy had just joined our project. One fine Michigan morning, I had the good fortune to pair up with him. After a quick analysis of our task, he whipped together a brief test case and we watched it fail. Aslak slid the laptop over to me and prompted me to pass the test. I smiled, wondering whether this technique had spontaneously popped up on different continents (Aslak was based in the UK). I quickly passed the test and slid the laptop back to Aslak. He immediately slid the laptop back and prompted me to write the next test. I struggled to pick up on where he was headed with the first test, but eventually slid the laptop back to him with a failing test.

We followed this cycle all morning. It was an awesome way to work with and learn from an exceptional developer such as Aslak. This back-and-forth style of development became the standard way we developed together on the project. A few weeks later, I was once again fortunate enough to pair program with another exceptional programmer: Dave Astels.

The task ahead of us was not an easy one. We needed to integrate most of the tasks I had completed during the iteration, tying them together in two different contexts. After we had acquired our ritual morning coffee, Dave started us off with a test case [ping]. I was feeling a little grumpy (and lazy) and I passed the test by hard-coding the value with which Dave’s mock object was expecting to be called. Then I wrote a slightly more rigorous test in order to force Dave to implement the code that he had tried to get me to write [pong]. He chuckled (as if to say I was in over my head), whipped together the necessary code, and wrote the next test--lickety-split [ping].

The morning went by very quickly as a rhythm developed in our pings and pongs. Any time either of us passed a test we looked for opportunities to remove duplication or make our intentions more explicit in the design. There was a curious mix of competition and collaboration. And then, quite suddenly, we were done. The design was so simple it almost felt wrong. I was proud of it.

In December 2004 I rotated onto another ThoughtWorks project and introduced this back-and-forth development technique to my first pair-programming partner. The thought occurred to me that naming this technique might make sharing the concept easier. After blogging about it, I discovered on Ward’s wiki that it is called ping-pong programming.

There are certainly many programming scenarios where this style of development might not be appropriate, but for the several teams that I've worked with, it has provided some helpful structure to our pair programming sessions. I know there are some bored pair programmers out there, staring silently as their partner drives for hours on end. If that’s you, consider giving ping-pong programming a try.

For someone who loves games and competition, the rhythm that develops in these programming sessions feels like home. When it’s working right, it is competitive and collaborative at the same time. As you compete to take ever-smaller steps, you are collaboratively and incrementally building up a rigorously tested set of barely sufficient objects.

Further Reading
Extreme Programming: http://extremeprogramming.org/
Ward’s Wiki: http://c2.com/cgi/wiki
Ping-Pong Programming: http://c2.com/cgi/wiki?PairProgrammingPingPongPattern
Mock Objects: http://mockobjects.com/

About the Author
Dave Hoover spends his days struggling to keep up with his fellow ThoughtWorkers, his wife, and his three children. He enjoys learning about and contributing to the craft of software development. Dave used to have a respectable job as a family therapist. He still wonders how he got here. You can read Dave's blog at http://redsquirrel.com/cgi-bin/dave.

Back to Top
 
 


Member Comments
Add Your Comment
 
Comment:    
by john palmer 5/3/2006

This same concept was recently introduced by Patterns and Practices team members. They called it the "pair-programming game" and there is a webcast on msdn events about it. the interesting thing is they see it as a way to show the benefits of test-driven development along with pair programming. The critical part is to make sure you do not skip the re-factor step in the process!!!

 
 
Comment:    
by Mary Ann Dempster 6/17/2005

How well does this concept work when developing web transactional applicationa? Users want the product yesterday, and I was wondering how well this would work in a hurry-up culture?

Author's Response:
6/17/2005    
To use this practice, you need tight feedback loops and the ability to take small steps. If every test reqires a restart of a web container, P3 could lose some of its power. If users want the product yesterday, you've got bigger problems than any one practice is going to solve. Does your hurry-up culture allow for pair programming? For writing tests first?

 
 
Comment:    
by J ’Brody’ Brodock 6/10/2005

Interesting article and a very interesting concept, thank you!!! I have been experimenting with pairs testing for the past couple years and have had mixed success but I can see how this would apply to a testing organization. I was wondering if you could expand on how you would envision how a test organization using this concept. And, if you have seen it used by a QA team.

Author's Response:
6/11/2005    
I haven't seen it used by a QA team, but I envision testers and developers ping-pong programming just like two developers would. Yes, this might be slow-going in the short term, but the added testing rigor and tester/developer collaboration would pay off in the long run.

 
 
Comment:    
by Ben Hogan 6/10/2005

I was introduced to P3 by Joe Walnes in London, but he called it "The Red-Bar Green-Bar Game", after the JUnit gui results, I'm not sure if he re-invented it himself or renamed Ward's game.

Author's Response:
6/10/2005    
From what I know of Joe, I wouldn't be surprised if he came up with it himself. But I also know that he and Aslak have worked together. I'm sure it's been "invented" many times over. By the way, I wouldn't assume that just because someone created a page about P3 on Ward's wiki, that it's "Ward's game".

 
 
Comment:    
by Andrew Raybould 6/8/2005

Dave, This looks very interesting, and as you note, seems to address the problem of fully engaging both participants in pair programming. I wonder if there are a couple of useful variants, which would help get QA involved early in the process: 1) 1 programmer + 1 tester working together; 2) 2 programmers + 1 tester, with the tester coming up with the test cases. I also share Mr. Whittaker's concern over the phrase 'short attention span', but I see no reason why this technique cannot be combined with adequate analysis and verification of requirements and design.

Author's Response:
6/8/2005    
There are a variety of variants to Ping-Pong Programming. Or, more accurately, Ping-Pong Programming is one of many ways that test-driven development and pair programming can be combined. Involving testers in this experience sounds like a great idea, particularly if they are willing to play the same role as the developer in which they are alternating between writing tests and passing tests.

 
 
Comment:    
by Joe Strazzere 6/6/2005

I can see where this could be fun. But is it effective?

 
 
Comment:    
by Mike Whittaker 6/6/2005

The phrase "short attention span" springs to mind ! Do you really want to encourage this in your developers, rather than a more careful checking of the functionality ?

 
Back to Top



 
Ads By Google
What's This?
 
 



About Us   |   Contact Us   |   Terms & Conditions   |   Privacy Policy   |   RSS Feed



© 2013 StickyMinds.com. All rights reserved.
PNSQC

Tricentis



STARWEST