Pair Programming Process Script

Purpose

    To guide you in how to work as a pair programming team. 

Requirements

Directions

    Planning

    1. Obtain a printed copy of a Pair Programming Log.
    2. In the Log header fill in the fields for both programmer names and the name of the program you are constructing.
    3. Determine who will initially be Driver and who will be Coach (or "navigator").  The driver is the person who holds the pencil, pen or keyboard and records the problem solving notes and solutions.  The Coach provides strategic and tactical direction.

    Design

    1. Record the date and Start time on the first line of the Log.  Enter "DESIGN" as the activity. Enter the driver's initials in the Comment field.
    2. Read the problem description. If there is ambiguity, inconsistency, omission or other error, ask the instructor for clarification.  Record the clarification in your lab notebook.
    3. When the requirements are clear, create a test plan and write it in your lab notebook.  A test plan is a series of test cases that will be used to verify the correctness of your solution.  Each test case is numbered and contains the actual input data that will be provided to the program, along with the expected results that should be produced. 
    4. Create a design of a solution.  This is any kind of outline of the solution that you create before writing actual programming statements.  For example, a design might be a class diagram, method specifications, flowchart, pseudocode, or interaction diagrams.  Write your design in whatever form you normally use in your lab notebook.
    5. This phase ends when you have a clear enough solution that you are ready to translate it into source code.  Usually that means you have detailed algorithms on which you have performed a "desk check" to verify that your logic is correct.
    6. Record the Stop time for this activity in the Log and compute the Delta time.
    7. If you change roles at any time record the Stop time and start a new entry with the initials of the new Driver.

    Code

    1. Record the date and Start time on the next line of the Log.  Enter "CODE" as the activity. Enter the driver's initials in the Comment field.
    2. Write the code for the unit, translating the design into actual programming language statements.  You may write the code in your lab notebook or type the code into the source file using a text editor. 
    3. Review the completed code for correctness, perhaps with a "desk check".
    4. This activity is finished when you are ready to compile your module the first time.
    5. Record the Stop time for this activity in the Log and compute the Delta time.
    6. If you change roles at any time record the Stop time and start a new entry with the initials of the new Driver.

    Compile

    1. Record the date and Start time on the next line of the Log.  Enter "COMPILE" as the activity. Enter the driver's initials in the Comment field.
    2. Compile the module.
    3. Repair the source code for any errors reported by the compiler.
    4. Repeat steps B - D until the compiler reports no errors. This phase ends with the first clean compile.
    5. Record the Stop time for this activity in the Log and compute the Delta time.
    6. If you change roles at any time record the Stop time and start a new entry with the initials of the new Driver.

    Test

    1. Record the date and Start time on the next line of the Log.  Enter "TEST" as the activity. Enter the driver's initials in the Comment field.
    2. Execute the compiled module, providing the input data as required by the Specification.
    3. Verify the correctness of your solution using whatever testing techniques you normally use.
    4. Repair the source code for any defects you find.
    5. Repeat steps B - D until you are satisfied that the code is correct.
    6. Submit your solution to the Web-CAT grading system online.
    7. Repair your work for any errors reported by the grading system.
    8. Repeat steps F - G until the grading system reports no errors.
    9. If you change roles at any time record the Stop time and start a new entry with the initials of the new Driver.

    Summary

    1. Find the sum of the delta times for each Driver for all entries in the Log.
    2. At the bottom of the form enter each programmer name and the total time they spent driving.
    3. Add the two driving times together and enter "Total Time: " and the sum.
    4. Optionally determine the size of your program using the Lines of Code Counter.  At the bottom of the form enter "LOC:" and the count.

Products



FAQ


Q: What if I'm designing and I'm not sure about some implementation detail? If I write experimental code can I count that as design activity?

A: Yes, as long as you discard the experimental code and don't reuse even a single line.

For example, say you want to create a string from an array of characters, and the API shows the constructor:
public String(char[] chars, int index, int count)
You want to know what happens if count is greater than the number of characters in the array. You try to find some documentation explaining the answer but are unsuccessful. So you decide to write a tiny program to find out.

public class StringSpike
{
    static 
    {
       char[] letters = {'h','i',' ','b','y','e'};
       String words = new String(letters,1,10);
    }
}
You can still consider this as the design phase, as long as you delete the program when you find out what you need to know. If you reuse even a single line, then we need to consider this as coding phase, because it could have defects that effect the rest of the solution.


Q: I'm not always certain which phase I'm in. Sometimes the distinction between design and coding is vague.

A: Yes, this is sometimes confusing, because many students don't have a clear distinction in their mind between designing and coding. Usually this is because many students haven't been taught an explicit design notation, nor do they have clear criteria for assessing when their design is complete

Design is the intellectually demanding task of determining "how is this going to work." Design determines the algorithm that will solve the problem. Ideally the design is represented in a language independent notation such as pseudocode that has no syntactical details. Coding should be a purely mechanical task of translating an already completed algorithm into high level language statements. (Note that entering the design pseudocode as comments in the module has a fringe benefit of producing "pre-documented" code. This will spare you having to add comments to your code after the fact.)

Frequently as students attempt to construct a solution they write a mishmash of english and half-coded language statements. Regardless of how it is written, this activity of algorithm creation is still recorded as design. At some point when they have a general understanding of the solution, they will go to the computer and start typing in source code. This starts the coding phase. Even if mentally they are still refining details of the design "on-the-fly" so to speak, their subjective sense is that they have shifted to writing code, so it should be recorded that way. Another clue is that the visible activity is writing programming language statements so this should be recorded as coding.

Sometimes a confident student will feel like they understand the solution well enough that they can keep the design in their head and they don't need to write down the algorithm. If this happens to you, enter 0 for the design time and go directly to implementation. Of course Dr. Dalbey discourages this practice, but if that is what you actually do you should record it that way in your Log. During implementation you may decide you are in over your head and you need to go back to design. If you abandon your coding effort and go back to writing algorithms, record that you stopped coding. Count the next efforts as design time even though it comes after some partial coding you have already done.

However, if you carry out the design mentally "on-the-fly" during coding, count this time as coding. (Note that you will have probably still have to enter the design pseudocode as comments after the fact).

Ultimately this is a subjective judgement, so enter what seems most appropriate to you. If you conclude that you really did switch back to a design phase, enter your time that way. If, however, you are designing as part of fixing a defect or hashing out an implementation problem, record your time in the phase in which you found and fixed the problem.  The criteria to keep in mind is initial design work is recorded as design, rework of flawed or inadequate design is not recorded as design.

Q: If I use the Eclipse IDE that compiles my source automatically, how do I record my coding time?

A: The first line you type into the IDE gets compiled, so count it as compile time. If you don't write your code on paper or in a text editor before you enter it into Eclipse, then there is no coding phase. If you go straight from design to typing in Eclipse, then enter 0 for the coding phase and put a comment "Entering/compiling code in Eclipse".

Q: During testing I have to re-compile my program after I've repaired a defect. Does this count as compile time?

A: No. The time you enter for the compile phase is the time you spend getting your program to compile successfully the first time. When you are first able to get a clean compile (no errors) the compile phase ends.

As you fix defects you find during testing, these changes must be recompiled; this time should be included as part of the test phase.

With some interpretive and 4GL languages (e.g. Python), there is no compile time. In this case, enter 0 for the compile phase and go directly from code to test.

Q: During testing I discover a design flaw. As I rework the design, does that count as design time?

A: No. Rework resulting from defects always counts as time during the phase in which the defect is found and fixed. Correcting code, changing the design, and re-compiling during testing all count as test time.

Q: In what phase do I record the time for writing test cases?

A: Record them in the phase you write them. If you write your test cases prior to coding, count it as design. If you wait until after coding to determine your test inputs and expected outputs, count it as testing.


Document History
9/21/09  JD   Modified "Basic" script for use with programmng pairs.

Copyright © 2009 by John Dalbey