Get a Pair Programming Partner
Pair Programming is an Extreme Programming best practice. The basic rule regarding pair programming in XP is that all
production code is developed in pairs. One programmer has the responsibility to complete a task. That programmer asks
other programmers to pair with him to complete the task. The pairings are short term, usually less than half a day.
Find a partner who has experience or skill you need to complete your task. Your task may include modifying a database
table. Ask the person on the team most knowledgeable to help you effectively use the database API. Later, you might
need to display the data in a GUI window, but you have not seen that part of the GUI. Get someone who knows about it to
help.
|
Write Failing Test Case
When looking at an Engineering Task, you should consider how to add the capability to the system. Does the system
require new classes? Are there classes that would be useful? Regardless of how these decisions come out, the addition
of functionality requires the creation of a test case. You write the test case to demonstrate that a portion of the
functionality you need isn't in the system. This test case should fail.
|
Write Code to Make Tests Pass
When you have a failing test case, you then write only the code that is necessary to satisfy the test case. Test cases
should have a very narrow focus. A failing test case may trigger the creation of a new class or method named in the
test case, or it may simply require you to add more code to existing classes and methods.
|
Refactor Immediately
After the test case passes, go back and make the code as clean as possible. Have you added code to a method and caused
the method to have more than one primary job? If so, extract a method. Has a class grown too large? Consider extracting
a class. Have you noticed duplication? Refactor to remove it.
|
Repeat Until Engineering Task is Done
The preceding three steps should be done in sequence over and over until you and your pair partner are done with the
engineering task. It is important to refactor as you go because refactoring, even on a micro-scale, makes additional
work easier.
|
|