UPI Study › Courses › Software Engineering › Free lessons › Lesson 5.5 Free with a free account
XP Engineering Practices: Pair Programming, TDD, Continuous Integration, and Refactoring
Software Engineering · Chapter 5: Agile Methodology in PracticeSection 5.5 · lesson 35 of 1037 min · free with a free account
Free preview
Create a free account to keep watching
It takes a minute and costs nothing. Your free account unlocks all of Chapter 1 and 3 more lessons of Software Engineering.
Lesson complete
Earn the 3 college credits for Software Engineering
Enrolling adds a quiz after each lesson, the graded work and the official transcript. Recommended for credit by NCCRS.
Next lesson: Comparing Agile Process Frameworks →← The 5 Core Values of Extreme Programming and the Culture They CreateNext lesson: Comparing Agile Process Frameworks →
In this lesson
Pair programming, TDD, continuous integration, and refactoring.
- Explain what XP adds to the generic agile lifecycle
- Describe pair programming, and the driver and navigator roles
- Describe the TDD cycle, and continuous integration
- Explain why the 4 practices reinforce each other
Transcript
Everything said in the video, section by section (950 words). Read along, or search it.
Agile Methodology in Practice
XP Engineering Practices
The agile lifecycle says work happens in repeating cycles. But it does not say how the code itself gets written inside one. Extreme Programming answers that directly, with four tightly linked engineering practices. This section covers pair programming, test-driven development, continuous integration, and refactoring, and why they belong together.
Inside the Cycle
How the Code Gets Written
Extreme Programming, usually shortened to X P, focuses on how code gets produced, at a sustainable, high-quality pace. It cares more about that than about roles or scheduled events. Four of its best-known practices are pair programming, test-driven development, continuous integration, and a particular way of handling refactoring. They are meant to be used together, as a coherent system, not sampled individually from a menu. Each one makes the others more effective, and the protection X P is known for comes largely from that combination.
Pair Programming
2 People, 1 Keyboard
In pair programming, two people work together at a single workstation, on the same code, at the same time. One person, the driver, is actively typing. The other, the navigator, reviews each line as it is written, thinks ahead, and catches mistakes before they are ever committed. The two roles swap regularly, so both people stay actively engaged, rather than one simply watching.
Pair Programming
Review in Real Time
The value comes from review that happens continuously, in real time, rather than later, after the code is written. Problems get caught immediately, instead of being discovered in a separate review step. Knowledge about the code spreads across the team as the work happens, rather than depending on documentation written afterward. And because a second person is thinking through every decision as it is made, the code tends to be simpler, and more carefully considered.
Figure 1
Red, Green, Refactor
Test-driven development, or T D D, is a discipline about the order in which code gets written. First, write a small test for behavior that does not exist yet. The test necessarily fails. That is the red step. Next, write just enough code to make that test pass. That is the green step. Finally, improve the code's internal structure, while the now-passing test protects against breaking it. That is the refactor step. Then the loop starts again. Each pass often takes only minutes.
TDD in Miniature
The Test Comes First
Here is the cycle in miniature. First, the test. It checks that adding two and three gives five. Running it fails, because the add function does not exist yet. Then just enough code to pass. A function that returns the sum of its two inputs. Now the test passes. Notice what gets left behind. Every loop leaves a test in place. So a growing, trustworthy suite of automated tests builds up naturally, as the code is written, rather than as a separate activity afterward.
Continuous Integration
Merging Constantly, Not Eventually
Continuous integration is about keeping everyone's work together. Rather than letting pieces of work drift apart for days or weeks, everyone's changes are merged into one shared version of the code, many times a day. Each merge automatically triggers a fast check, typically the test suite built up through T D D, confirming that nothing has broken. The value is catching integration problems while they are still small and cheap to fix, rather than piling them into one large, painful merge later. The specific tools are a separate topic. The discipline is what matters. Merge often, check automatically, and keep the shared code working.
Worth Noticing
Each Practice Covers the Next
It is worth noticing how these practices depend on each other. Pairing catches a bad change before it is committed. T D D produces the safety net that makes fast checks meaningful. And continuous integration makes sure that safety net gets exercised constantly, not occasionally. Adopt just one of them, and most of the protection the whole system provides together is lost.
Refactoring in XP
The Third Beat of the Cycle
Refactoring means improving a piece of code's internal structure, without changing what it does from the outside. Inside X P, refactoring is not scheduled as separate cleanup work for later. It is the third beat of the T D D cycle, happening continuously. What makes frequent refactoring safe is the test suite that T D D produces. A change to the code's structure can be checked instantly against tests that already exist, giving real confidence that behavior has not quietly changed.
Table 1
The 4 Practices Together
Here are the four practices together. Pair programming is two people at one workstation, with continuous review. It catches problems at once, and spreads knowledge across the team. T D D writes a failing test, then the code to pass it, then refactors. It produces a trustworthy, growing test suite. Continuous integration merges everyone's changes many times a day, catching integration problems while they are small. And refactoring improves structure continuously, protected by the tests, so the codebase stays healthy without a cleanup phase. Together, they are what make embracing change genuinely safe. A team can respond to a changed requirement without dreading what else might break.
Key Terms
The Vocabulary of This Section
Let's lock in the key terms. Pair programming is two people working at one workstation on the same code, as driver and navigator, swapping roles regularly. Test-driven development means writing a failing test before the code that satisfies it, then refactoring, in a short, constantly repeated cycle. Continuous integration means merging everyone's changes into one shared version many times a day, each time checked automatically against the tests. And refactoring, in X P, is the continuous, test-protected improvement of code structure, built directly into the T D D cycle.
Key Takeaways
What to Carry Forward
To pull this together. Extreme Programming defines how code actually gets written inside each cycle. Pair programming gives continuous, real-time review, with the driver and navigator swapping roles regularly. T D D runs through red, green, and refactor, and leaves a trustworthy test suite behind. Continuous integration merges and checks everyone's work many times a day. And the four practices reinforce each other. Together, they make change safe.
About Software Engineering at UPI Study
Software Engineering (Computer Science 301) is a self-paced online course of 103 video lessons in 15 chapters, from process models and agile to requirements, design, user interfaces, reliability, security and project management. It carries a NCCRS credit recommendation for 3 semester credits.
Every lesson transcript is free on pages like this one, and the videos are free with a free UPI Study account. Enrolling adds a practice quiz after each lesson, the graded work and final exam that earn the credit, lifetime access, and an official transcript on completion. UPI Study has helped over 130,000 students with college credits. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Enroll now → Course details Download the syllabus All Computer Science courses Every course with PRO →
Why take it here
Why students take Software Engineering with UPI Study
Where the credit goes
Universities that work with NCCRS
Software Engineering carries a NCCRS credit recommendation. These universities work with NCCRS; some are UPI Study's signed partners. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Thomas Edison State UniversitySigned partner
University of the PeopleSigned partner
Charter Oak State CollegeSigned partner
Strayer UniversitySigned partner
Columbia Southern UniversitySigned partner
Indiana TechSigned partner
Penn StateWorks with NCCRS
Southern New Hampshire UniversityWorks with NCCRS
SUNYWorks with NCCRS
+many more cooperating universitiesFind my college →Find my college → Not listed? Ask Athena in the corner of this page, or book a 15-minute call.
FAQ
Questions students ask us
About XP Engineering Practices: Pair Programming, TDD, Continuous Integration, and Refactoring
What is pair programming and how do the driver and navigator roles work?
What is the red-green-refactor cycle in test-driven development?
What is continuous integration?
Why should pair programming, TDD, and continuous integration be used together?
About the Software Engineering course
How many college credits is Software Engineering?
How much does Software Engineering cost and what is included?
Which universities accept UPI Study credits?
How long does Software Engineering take?
How are the exams done?
How do my credits reach my college?
Ready for the full course? Earn 3 credits in Software Engineering.
103 video lessons, a quiz after each one, and the graded work that earns the credit. Recommended for credit by NCCRS.
3 credits · NCCRSEnroll →