Scrum and Kanban tell you how to organize the work, but not how to write the software. That omission is deliberate, and it comes at a price: a team can hold every Scrum event and respect the WIP limits on its board and still produce code that is harder and harder to change, gets integrated late, and reaches users with defects. That is exactly what Órbita's two teams discovered in their joint retrospective on September 2. Extreme Programming (XP) is the agile framework that fills that gap: a set of values, principles, and technical practices that let you change software often, cheaply, and without quality paying the price. In this lesson you will study XP's values and practices and look in detail at the most influential ones: test-driven development (with a complete example in Python and pytest), refactoring, pair and ensemble programming, continuous integration with trunk-based development, simple design, collective code ownership, coding standards, and sustainable pace. You will finish by seeing how María's team adopted these practices in experiment EXP-02 and what results it got.
- XP: Origin and Purpose
In Overview of Agile Frameworks: Scrum, Kanban, XP, and Lean you saw XP in a nutshell. Let's recap the essentials and go deeper:
- Who and when: Kent Beck developed XP in the second half of the 1990s, largely during a Chrysler payroll project known as C3, together with Ron Jeffries and with ideas shared with Ward Cunningham. He introduced it in the book Extreme Programming Explained: Embrace Change (1999). The second edition (2004), written with Cynthia Andres, reorganized the framework: it added the value of respect, made the principles explicit, and regrouped the practices into primary and corollary practices.
- Why "extreme": the idea is to take practices that were already known to work and push them to the extreme. If reviewing code is good, let's review it all the time (pair programming). If testing is good, let's test before we even write the code (TDD). If integrating is good, let's integrate several times a day (continuous integration).
- What problem it solves: flattening the cost-of-change curve you saw in Traditional vs. Agile Methodologies. An agile team welcomes changing requirements, even late, but that is only sustainable if changing the code is cheap. XP provides the technical mechanisms that make it possible.
XP doesn't compete with Scrum; it complements it. Scrum defines when the team plans, reviews, and improves; XP defines how each Increment is built so that it meets the Definition of Done without piling up debt. That is why Órbita decided in March, in its decision record, that both teams would adopt XP practices "progressively." The joint retrospective showed that "progressively" had turned into "never."
- XP Values and Principles
2.1. The Five Values
| Value | What it means | How it shows up day to day | Example at Órbita |
|---|---|---|---|
| Communication | Most project problems start with something someone knew and didn't pass on | Face-to-face conversations, pairing, visible information | Support didn't know what was changing in the API with each deployment |
| Simplicity | Do the simplest thing that could possibly work today, without building for an imagined future | Small designs, removing code you don't need | Not preparing the import for ten formats when Grupo Alba asks for one |
| Feedback | Find out as soon as possible whether something works: from the code, the customer, the team | Tests in seconds, integration several times a day, frequent deliveries | A 4.5-day branch delays by 4.5 days the news that something is broken |
| Courage | Tell the truth about the state of the work and dare to change what isn't working | Throwing away code that doesn't serve, raising a problem early, refactoring | Ana proposed spending capacity on contract tests in the middle of Release 2 |
| Respect | Everyone on the team matters, and so do the people who use and maintain the software | Nobody works on something that harms someone else; you take care of whoever inherits the code | An API change that breaks 1.0 shifts the problem onto Support |
The values are deliberately abstract. Beck sees them as criteria for deciding when no practice tells you what to do. When a situation isn't covered, the question is: which option communicates better, is simpler, gives us feedback sooner, takes courage, and respects the people involved?
2.2. The Principles: The Bridge Between Values and Practices
In the second edition, Beck added an intermediate layer: the principles, which turn the abstract values into more concrete guidance. Some of the most useful ones for a team that is just starting out:
- Humanity: software is built by people, who have needs for safety, accomplishment, belonging, and growth. A practice that ignores them won't last.
- Economics: practices must make economic sense; refactoring is not an end in itself, but a way to keep future change cheap.
- Improvement: the aim is not perfection up front, but doing the best you can today and making it better tomorrow.
- Quality: sacrificing quality doesn't make you faster; the TaskMaster 1.0 team learned that through two months of overtime.
- Baby steps: many small, verified changes are safer than one big one.
- Failure: if you don't know which option works, trying several and failing cheaply is a way of learning.
- Accepted responsibility: responsibility isn't assigned, it is accepted; whoever commits to a task also decides how to do it.
- The Map of XP Practices
3.1. From the First to the Second Edition
The first edition proposed twelve practices: the planning game, small releases, metaphor, simple design, testing, refactoring, pair programming, collective ownership, continuous integration, the 40-hour week, on-site customer, and coding standards. The second edition reorganized them into primary practices, which can be adopted independently and deliver immediate value, and corollary practices, which only work once the primary ones are in place.
| Primary practice (2nd ed.) | What it involves | Where you have seen it or will see it in the course |
|---|---|---|
| Sit together | The team works in a shared space, physical or virtual, that makes communication easy | Collaboration in Remote and Hybrid Agile Teams |
| Whole team | The team brings together all the skills needed to deliver | Cross-functional team in Scrum Roles |
| Informative workspace | The state of the work can be seen at a glance | Information radiators in Monitoring and Controlling Agile Projects |
| Energized work | Work only as many hours as you can be productive | Sustainable pace, section 8 |
| Pair programming | Two people, one problem, one keyboard | Section 6 |
| Stories | Units of functionality visible to the customer | User Stories and Acceptance Criteria |
| Weekly cycle | Plan each week what will be delivered | Equivalent to the Sprint |
| Quarterly cycle | Plan themes and goals each quarter | Releases and roadmap in Backlog Prioritization and Value Management |
| Slack | Include optional tasks in the plan to absorb the unexpected | The 15% reserve for technical debt |
| Ten-minute build | Automatically build and test the whole system in ten minutes or less | Section 7 |
| Continuous integration | Integrate and test changes every few hours | Section 7 |
| Test-first programming | Write a failing test before changing the code | TDD, section 4 |
| Incremental design | Invest in the design a little every day | Simple design and refactoring, sections 5 and 8 |
The corollary practices include daily deployment and incremental deployment (you will see them in DevOps and Continuous Delivery in Agile Teams), root-cause analysis (you already practiced it in Continuous Improvement in Agile Projects), shared code or collective ownership, a single code base, team continuity, and the negotiated scope contract (which you will come back to in Agile Transformation and Cultural Change).
3.2. The Practices Reinforce Each Other
A central idea in XP is that the practices are not an à la carte menu: they support one another. Adopting just one usually fails.
flowchart LR
TDD[Automated tests<br/>with TDD] --> REF[Fearless<br/>refactoring]
REF --> DS[Simple design]
DS --> TDD
TDD --> CI[Continuous integration]
CI --> PC[Collective ownership]
PP[Pair programming] --> PC
EC[Coding standards] --> PC
PP --> EC
CI --> RS[Sustainable pace]
How to read the diagram:
- Each arrow means "makes possible" or "makes easier." Automated tests let you refactor without fear, because they warn you if something breaks; refactoring keeps the design simple; and a simple design is easier to test.
- Continuous integration is only safe if there are automated tests: integrating untested code several times a day just spreads bugs faster.
- Collective ownership needs three supports: tests (to change other people's code safely), pairing (so knowledge flows), and standards (so all the code reads the same way).
- Sustainable pace is the result: when problems are caught early, the weeks of "firefighting" go away.
- Test-Driven Development (TDD)
4.1. The Red-Green-Refactor Cycle
Test-driven development (TDD) is the practice of writing an automated test that fails before writing the code that makes it pass. Beck described it in detail in Test-Driven Development: By Example (2002). You work in very short cycles of a few minutes:
flowchart LR
R[RED<br/>write a small<br/>failing test] --> V[GREEN<br/>write the minimum code<br/>to make it pass]
V --> F[REFACTOR<br/>improve the design<br/>without changing behavior]
F --> R
- Red: you write a test for a single new behavior and run it. It must fail, and for the expected reason. If it passes without changing anything, either the test is wrong or the behavior already existed.
- Green: you write the minimum code that makes the test pass, even if it isn't elegant. The goal is to get back as quickly as possible to a state where everything works.
- Refactor: with all the tests green, you improve the code (names, duplication, structure), running the tests after each small change.
TDD is not, first and foremost, a testing technique but a design technique: it forces you to think about how the code will be used before you write it, it produces small pieces that are easy to test, and it leaves behind, as a by-product, a suite of tests that documents the behavior.
4.2. The Case: A Space with Twelve Members
On Thursday, September 10, during Sprint 14, someone on one of Grupo Alba's teams told Support about something odd: their space had twelve members, even though the limit is ten. Lucía diagnosed it within an hour: the space had nine members and three pending invitations. Because acceptance criterion 3 of PB-02 ("once the limit is reached, no more invitations can be created") was only checked when the invitation was created, all three people were able to accept it, and the space went over the maximum.
Carmen was on call (EXP-03) and took it on with Ana. They decided to fix it as a pair and with TDD, with Carmen at the keyboard so she could learn that part of the code. This was the invitation acceptance code:
# invitations.py (before the fix)
from dataclasses import dataclass, field
from datetime import datetime
@dataclass
class Space:
members: set = field(default_factory=set)
@dataclass
class Invitation:
email: str
created: datetime
def accept_invitation(invitation, space, now):
if (now - invitation.created).total_seconds() > 7 * 24 * 3600:
raise ValueError("This invitation has expired")
if invitation.email not in space.members:
space.members.add(invitation.email)What each part does:
@dataclassis a Python decorator that automatically creates a simple class for holding data.Spaceholds asetof its members' email addresses;field(default_factory=set)makes each new space start with its own empty set.Invitationholds the invitee's email address and the moment the invitation was created.accept_invitationreceives the invitation, the space, and the current time (now). Receiving the time as a parameter, instead of reading the clock inside the function, is what makes it possible to test expiration without waiting seven days.- The first condition calculates the elapsed seconds and compares them with the number of seconds in seven days (
7 * 24 * 3600). If they are exceeded, it raises an error. - The second one adds the person only if they weren't already a member. It doesn't check the limit of ten: that is the defect.
There were two tests, written in Sprint 1:
# test_invitations.py (existing tests)
from datetime import datetime, timedelta
import pytest
from invitations import Space, Invitation, accept_invitation
CREATED = datetime(2026, 9, 8, 10, 0)
ONE_DAY_LATER = CREATED + timedelta(days=1)
def space_with(n):
return Space(members={f"person{i}@example.com" for i in range(n)})
def test_accepting_a_valid_invitation_adds_the_member():
space = space_with(4)
accept_invitation(Invitation("[email protected]", CREATED), space, ONE_DAY_LATER)
assert "[email protected]" in space.members
def test_expired_invitation_cannot_be_accepted():
space = space_with(4)
with pytest.raises(ValueError):
accept_invitation(Invitation("[email protected]", CREATED), space,
CREATED + timedelta(days=8))
assert "[email protected]" not in space.membersHow these tests work with pytest, the most widely used testing tool in Python (you install it with pip install pytest and run it with the pytest command in the project folder):
- pytest looks for files whose names start with
test_and, inside them, functions that start withtest_. Each one is a test. CREATEDandONE_DAY_LATERare fixed dates. Using fixed dates means the test always gives the same result, no matter what day it runs.space_with(n)is a helper function that creates a space withnmade-up members ([email protected],[email protected]...). It saves you from repeating that code in every test.assertchecks a condition: if it is false, the test fails.with pytest.raises(ValueError):checks that the code in the block raises an error of that type. If it doesn't, the test fails.
4.3. Cycle 1: The Defect, in Red
The first rule when fixing a defect with TDD: before touching the code, write a test that reproduces it. That proves you understand the problem and guarantees it won't come back.
def test_maximum_is_not_exceeded_on_accept():
space = space_with(10)
with pytest.raises(ValueError):
accept_invitation(Invitation("[email protected]", CREATED), space, ONE_DAY_LATER)
assert len(space.members) == 10- You set up a space that is already full (10 members) and try to accept a valid invitation.
- You expect an error and, on top of that, that the space still has 10 members: the second check ensures that nobody was added before the failure.
Carmen ran pytest -q (the -q option shows condensed output):
..F [100%]
def test_maximum_is_not_exceeded_on_accept():
space = space_with(10)
> with pytest.raises(ValueError):
E Failed: DID NOT RAISE <class 'ValueError'>
FAILED test_invitations.py::test_maximum_is_not_exceeded_on_accept - Failed: ...
1 failed, 2 passed in 0.01s- Each dot is a passing test and the
Fis a failing one. pytest shows the exact line (>) and the reason (E): aValueErrorwas expected and wasn't raised. - This is the right red: the test fails precisely because of the defect you want to fix.
Green. Carmen added the simplest possible check:
def accept_invitation(invitation, space, now):
if (now - invitation.created).total_seconds() > 7 * 24 * 3600:
raise ValueError("This invitation has expired")
if len(space.members) >= 10:
raise ValueError("The space has reached the maximum of 10 members")
if invitation.email not in space.members:
space.members.add(invitation.email)len(space.members) counts the members; if there are already 10 or more, the acceptance is rejected with the same text the interface shows when creating invitations. All three tests passed (3 passed).
4.4. Cycle 2: The Awkward Question
Ana, as navigator, asked: "What if the person accepting is already a member? With a full space, do we give them an error?" Acceptance criterion 5 says that someone who is already a member "is informed and no duplicate is created"; they shouldn't get the space-full error. They turned it into a test:
def test_existing_member_is_not_duplicated():
space = space_with(10)
accept_invitation(Invitation("[email protected]", CREATED), space, ONE_DAY_LATER)
assert len(space.members) == 10> raise ValueError("The space has reached the maximum of 10 members")
E ValueError: The space has reached the maximum of 10 members
FAILED test_invitations.py::test_existing_member_is_not_duplicated - ValueErr...
1 failed, 3 passed in 0.01s[email protected]is already a member of the 10-person space. The cycle 1 fix checks the limit before checking whether the person is already a member, and that is why it raises an error it shouldn't.- Without this test, fixing the defect would have introduced another defect. It is an example of why TDD moves forward one behavior at a time.
Green. Changing the order of the checks was enough:
def accept_invitation(invitation, space, now):
if (now - invitation.created).total_seconds() > 7 * 24 * 3600:
raise ValueError("This invitation has expired")
if invitation.email in space.members:
return
if len(space.members) >= 10:
raise ValueError("The space has reached the maximum of 10 members")
space.members.add(invitation.email)If the person is already a member, the function ends (return) without doing anything; only after that is the limit checked. Four tests green.
4.5. Cycle 3: The Boundary Value
Sara, reviewing the pair's tests, asked the question any good tester would ask: "What happens at exactly seven days?" The criterion says the invitation "expires after 7 days," which means that at exactly seven days it is no longer valid. Boundary value tests are written on both sides of the boundary:
def test_accepted_one_minute_before_7_days():
space = space_with(4)
accept_invitation(Invitation("[email protected]", CREATED), space,
CREATED + timedelta(days=7, minutes=-1))
assert "[email protected]" in space.members
def test_expires_exactly_at_7_days():
space = space_with(4)
with pytest.raises(ValueError):
accept_invitation(Invitation("[email protected]", CREATED), space,
CREATED + timedelta(days=7))FAILED test_invitations.py::test_expires_exactly_at_7_days - Failed: DID NOT ... 1 failed, 5 passed in 0.01s
timedelta(days=7, minutes=-1)represents "seven days minus one minute."- The second test fails: the code uses
>(strictly greater than), so at exactly seven days the invitation is still accepted. It was a latent defect, there since Sprint 1, that nobody had noticed.
Green. Change > to >=. Six tests green.
With the tests green, the code works, but it has "magic" numbers (7 * 24 * 3600, 10) and it mixes different rules in a single function. It is time for the third step of the cycle, refactor, which is covered in the next section.
4.6. TDD in Context
- Unit, contract, and acceptance tests. TDD works with unit tests, which are small and very fast. EXP-02 also added contract tests: they check that the API still returns what the 1.0 app expects. And the Gherkin scenarios from User Stories and Acceptance Criteria can be automated as acceptance tests: many teams start a story by writing its acceptance scenario (which fails) and then go through several TDD cycles until it passes.
A sync contract test looks like this, simplified:
# test_sync_contract_1_0.py (illustrative: api_client is defined in another file)
FIELDS_USED_BY_1_0 = {"id", "title", "completed", "modified_at", "version"}
def test_sync_keeps_the_fields_used_by_1_0(api_client):
response = api_client.get("/sync?since=2026-09-01T00:00:00Z")
assert response.status_code == 200
for task in response.json()["tasks"]:
assert FIELDS_USED_BY_1_0 <= task.keys()-
api_clientis a pytest fixture: an object that pytest creates and passes to the test automatically (here, a client that sends requests to the API in a test environment). -
FIELDS_USED_BY_1_0 <= task.keys()checks that the set of fields the 1.0 app needs is contained in the fields the API returns. If someone removes or renames one, the test fails before it reaches production, which is exactly what wasn't happening over the summer. -
When not to use TDD. In a spike (an investigation whose code will be thrown away, like PB-07), in the visual exploration of an interface, or in proof-of-concept code, writing the test first adds little. What matters is not to confuse "it's hard to test" with "it isn't worth testing": the difficulty often points to a design problem.
- Refactoring
5.1. What It Is and What It Isn't
Martin Fowler, in his book Refactoring (1999; second edition in 2018), defines refactoring as a change to the internal structure of software that makes it easier to understand and cheaper to modify without changing its observable behavior. Three consequences:
- It isn't rewriting: you move forward in small steps, each of which leaves the code working.
- It doesn't add functionality: while you refactor, you don't change what the code does. Beck explains it with the image of the "two hats": you are either adding behavior or refactoring, never both at the same time.
- It needs tests: without a suite of automated tests, there is no way to know whether the behavior has been preserved. That is why TDD and refactoring go together.
5.2. Code Smells
Fowler and Beck coined the term code smells for the symptoms that suggest it's time to refactor. They aren't bugs; they are hints.
| Smell | Symptom | Usual refactoring |
|---|---|---|
| Magic number | A literal (10, 604800) whose meaning isn't obvious |
Replace it with a named constant |
| Duplication | The same logic in several places | Extract a shared function or method |
| Long function | A function that does several things | Extract functions with names that explain each step |
| Confusing name | proc(), data2, flag |
Rename to reveal intent |
| Feature envy | A function that mostly manipulates another object's data | Move the logic to the object that owns the data |
| Generic exception | Every error is a ValueError |
Introduce specific exceptions |
5.3. Refactoring the Invitations, Step by Step
Ana and Carmen applied four refactorings, running the tests after each one. This was the result:
# invitations.py (after refactoring)
from dataclasses import dataclass, field
from datetime import datetime, timedelta
MAX_MEMBERS = 10
INVITATION_VALIDITY = timedelta(days=7)
class InvitationExpired(ValueError):
"""The invitation is past its validity period."""
class SpaceFull(ValueError):
"""The space already has the maximum number of members."""
@dataclass
class Space:
members: set = field(default_factory=set)
def is_full(self):
return len(self.members) >= MAX_MEMBERS
@dataclass
class Invitation:
email: str
created: datetime
def expired(self, now):
return now - self.created >= INVITATION_VALIDITY
def accept_invitation(invitation, space, now):
if invitation.expired(now):
raise InvitationExpired("This invitation has expired")
if invitation.email in space.members:
return # already a member: no duplicate
if space.is_full():
raise SpaceFull(
f"The space has reached the maximum of {MAX_MEMBERS} members")
space.members.add(invitation.email)The four refactorings, in the order they were made:
- Replace magic numbers with constants:
MAX_MEMBERS = 10andINVITATION_VALIDITY = timedelta(days=7). The business rules are written down only once, at the top of the file, with a name that explains them. If the limit changes (Grupo Alba has already asked about larger spaces), it changes in one place. In addition, comparing twotimedeltavalues directly avoids counting seconds by hand. - Move the logic to the object that owns the data: the expiration check becomes the
expired()method ofInvitation, and the limit check becomes theis_full()method ofSpace. The main function now reads almost like the acceptance criteria. - Introduce specific exceptions:
InvitationExpiredandSpaceFull. Because they inherit fromValueError(that is whatclass InvitationExpired(ValueError)means), the existing tests, which expect aValueError, still pass: the observable behavior hasn't changed. The text in triple quotes ("""...""") is a docstring, a description that documents the class. - Make the tests more precise: with the code already refactored and green, they replaced
pytest.raises(ValueError)in the tests with the specific exception expected, for examplepytest.raises(SpaceFull). That way, a "space full" test can no longer pass by mistake if what actually fires is the expiration.
The final test file also imports the new exceptions:
The final run with pytest -v (the -v option shows the name of each test):
test_invitations.py::test_accepting_a_valid_invitation_adds_the_member PASSED [ 16%] test_invitations.py::test_expired_invitation_cannot_be_accepted PASSED [ 33%] test_invitations.py::test_maximum_is_not_exceeded_on_accept PASSED [ 50%] test_invitations.py::test_existing_member_is_not_duplicated PASSED [ 66%] test_invitations.py::test_accepted_one_minute_before_7_days PASSED [ 83%] test_invitations.py::test_expires_exactly_at_7_days PASSED [100%] ============================== 6 passed in 0.01s ===============================
Notice that the test names read like a specification of the behavior. Someone new to the team can understand the invitation rules just by reading that list. All the work, from Grupo Alba's report to the merged change, took the pair a little under three hours.
5.4. Refactoring Day to Day
- Continuous refactoring: most of it happens in the refactor step of each TDD cycle, in minutes. Many teams follow the Boy Scout Rule: leave the code a little better than you found it.
- Large refactorings: when a part of the system is badly deteriorated, like the 1.0 sync module, the work is planned as visible work, for example charged to the 15% technical debt reserve you saw in Monitoring and Controlling Agile Projects, and it moves forward in small steps over several Sprints, never as a complete rewrite done in secret.
- Tests first: before refactoring old code that has no tests, you write characterization tests, which pin down what the code does today (even if it isn't ideal), so you can catch any accidental change.
- Pair Programming and Ensemble Programming
6.1. Pair Programming
In pair programming, two people work together on the same task, with a single keyboard:
- The driver writes the code and thinks about the immediate detail.
- The navigator reviews each line as it is written, thinks about the overall direction, spots mistakes, and suggests the next test.
- The roles switch frequently, every 15-30 minutes or at every TDD cycle.
Common variants:
| Variant | How it works | When it fits |
|---|---|---|
| Driver-navigator | The classic form described above | General use |
| Ping-pong | One person writes a failing test; the other makes it pass and writes the next test | Combined with TDD; very balanced |
| Strong-style | Every idea must go through the other person's hands: whoever knows navigates, whoever is learning drives | Passing on knowledge, like Ana with Carmen |
| Remote | Shared screen and editor, with voice and video | Hybrid or distributed teams |
Notice that Ana and Carmen used strong-style pairing: Carmen drove because she was the one who needed to learn the sync for her on-call shifts.
Benefits and costs. Pairing reviews the code at the moment it is written, spreads knowledge (the system stops depending on a single person), keeps the focus, and makes it easier to onboard new people. In exchange, it is tiring and takes learning to work that way; not every task needs it. There is no universal figure for how much it raises or lowers the cost of development: it depends on the type of task and on the team. The useful question is which tasks it pays off for.
6.2. Ensemble Programming (Mob Programming)
Ensemble programming extends the idea to the whole team: several people, often the entire team, work on the same problem, at the same time, at the same computer. Woody Zuill popularized it based on his experience at Hunter Industries in the 2010s; today many people prefer the term ensemble programming, which avoids the connotations of "mob."
- One person drives and the rest navigate; the driver rotates on a timer, typically every 5-10 minutes.
- Strong-style is the norm: the driver doesn't decide, but turns what the group agrees on into code.
- Decisions, knowledge, and review all happen at once and for everyone.
| Way of working | Advantages | Drawbacks | Typical use |
|---|---|---|---|
| Solo | Maximum concentration; efficient for routine work | Knowledge doesn't flow; review comes afterward | Simple, well-understood tasks |
| Pair | Continuous review, knowledge shared between two | Fatigue; requires coordinating schedules | Delicate code, learning, complex defects |
| Ensemble | The whole team understands and decides; no handoffs or waiting | Looks "expensive"; poorly facilitated, part of the group gets bored | Hard problems, design decisions, team learning |
- Continuous Integration and Trunk-Based Development
7.1. Continuous Integration as a Practice, Not a Tool
Continuous integration (CI) is the practice of merging each person's work into the shared main branch frequently, at least once a day and often several times, and automatically verifying each integration with the full build and test suite. The term is attributed to Grady Booch (1991); XP made it a central practice, and Martin Fowler popularized it in a widely read article.
Here is the trap Órbita fell into: since March the team had had a continuous integration server, and its Definition of Done required that "the code is merged into the main branch" and that "automated tests pass on the continuous integration server." But each Developer worked on their own branch for 4.5 days on average and merged it at the end. They had the tool; they weren't practicing continuous integration. A simple test, often put forward by Jez Humble, lets you tell the difference:
- Does everyone merge their work into the main branch at least once a day?
- Are there automated tests that give you confidence the change hasn't broken anything?
- When the build breaks, is it fixed within minutes, as the top priority?
If any answer is "no," what you have is a CI server, not continuous integration.
7.2. The Conditions for Continuous Integration
| Condition | Why it matters | Órbita's situation in August |
|---|---|---|
| A single repository with everything needed to build | Nobody depends on files "on someone's laptop" | Met |
| Automated build | A single command builds and tests everything | Met |
| Self-testing build | If the tests don't fail when there is a bug, integrating gives you no safety | Partly: no API-1.0 contract tests |
| Everyone merges into the main branch daily | Conflicts are caught while they are still small | No: 4.5-day branches |
| Fast build (about ten minutes) | If it takes an hour, nobody waits for the result | About 14 minutes |
| A broken build is fixed immediately | A broken main branch blocks everyone | It was once broken for half a day |
7.3. Long-Lived Branches vs. Trunk-Based Development
flowchart TB
subgraph Long [Long-lived branches - August]
L1[Monday: Ana opens a branch] --> L2[4.5 days<br/>without merging]
L3[Monday: Carmen opens a branch] --> L4[4.5 days<br/>without merging]
L2 --> L5[Friday: merge<br/>with conflicts]
L4 --> L5
L5 --> L6[Manual testing<br/>late and rushed]
end
subgraph Trunk [Trunk-based - October]
T1[Small change] --> T2[Merged within hours<br/>with automated tests]
T2 --> T3[Next small change]
T3 --> T2
end
- In the long-lived branch model, each person's code diverges for days; conflicts and incompatibilities are all discovered together at the end, when they are most expensive to resolve. This is "integration hell."
- In trunk-based development, the whole team works on a single main branch (the "trunk"). Branches are allowed, but they are very short-lived: they last hours, a day at most, and they are used to review the change before merging it.
| Aspect | Long-lived (feature) branches | Trunk-based development |
|---|---|---|
| Life of a branch | Days or weeks | Hours, a day at most |
| Conflicts | Large and late | Small and frequent |
| Half-done work | Hidden in the branch | Merged, but hidden behind feature flags |
| Code review | Big changes that are hard to review | Small changes, quick review or review in pairs |
| Prerequisite | Few | Good automated tests and the discipline of small steps |
The usual question is: "How do I merge daily a feature that takes a week?" There are two techniques:
- Feature flags: half-finished code is merged and deployed, but turned off. Órbita's Definition of Done had mentioned them since version 1; how they are used in deployment is covered in DevOps and Continuous Delivery in Agile Teams.
- Branch by abstraction: to replace part of the system, you first create an intermediate layer that hides it, build the new implementation behind it little by little, and switch from one to the other when it is ready.
7.4. María's Team's Integration Agreements
For EXP-02, the team wrote these agreements in the repository, next to the Definition of Done:
# integration_agreements.yml - TaskMaster product team (v1, Sep 7, 2026)
integration:
min_frequency: "at least once a day per person"
max_branch_life: "1 working day"
before_merging:
- "pull the latest changes from the main branch"
- "run the unit tests locally"
incomplete_work: "merged behind a feature flag that is turned off"
broken_build:
priority: "top: whoever broke it fixes it or reverts their change"
time_to_fix: "10 minutes; otherwise, revert"
alert: "automatic message to the team channel"
build:
target_duration: "10 minutes or less"
includes: [static_analysis, unit_tests, api_1_0_contract_tests]
code_review:
paired_changes: "considered reviewed"
individual_changes: "reviewed by another person within 4 hours"How to read it:
min_frequencyandmax_branch_lifeare a direct translation of the EXP-02 hypothesis. They are measurable: the integration server records when each branch is opened and merged.broken_buildsets out the most important rule of continuous integration: a broken main branch is fixed before anything else. Reverting the change is not a failure; it is the fastest way to get everyone back to a working state.target_duration: "10 minutes or less"captures the XP practice of the ten-minute build. Getting from 14 down to under 10 required Ana to run the tests in parallel.includeslists what is checked on each integration; the contract tests are what EXP-02 adds.code_reviewresolves a typical conflict: if each change waits a day to be reviewed, branches get longer again. Pair work counts as review, and everything else has a short deadline.
- Simple Design, Collective Ownership, Coding Standards, and Sustainable Pace
8.1. Simple Design
Beck sums up simple design in four rules, in order of priority. Code is simple when it:
- Passes all the tests: first, make it work.
- Reveals intention: it is clear what it does and why (names like
is_full()rather thanchk()). - Has no duplication: each idea is expressed only once (the constants
MAX_MEMBERSandINVITATION_VALIDITY). - Has the fewest elements: no classes, functions, or layers that aren't needed.
Closely related is the idea of YAGNI (You Aren't Gonna Need It): don't build functionality or flexibility today for assumed future needs. When Grupo Alba asked to import tasks from a spreadsheet (PB-29), Carmen initially proposed a generic "connector" system for any format. The team decided to start with the CSV format Grupo Alba actually used: if a second format came along, the design would be generalized through refactoring, with the tests as a safety net. Simple design doesn't mean no design, but incremental design: you invest in the design a little every day, instead of a lot up front.
8.2. Collective Code Ownership
Collective ownership means that anyone on the team can improve any part of the code at any time, and that the whole team is responsible for all of the code. Its opposite is individual ownership ("Ana's module"), which creates bottlenecks and risks.
A useful indicator is the so-called bus factor: how many people would have to be missing for a part of the system to be left with nobody able to change it. In August, the bus factor for the sync was 2 (Ana and, in Support, Lucía), and for iOS publishing it had been 1 (Luis) until Carmen learned how to do it by pairing with him. Collective ownership isn't declared: it is built through pairing, tests, and standards.
8.3. Coding Standards
If the whole team works on all the code, it has to read as if a single person had written it. Coding standards are team agreements on formatting, naming, and structure. Today, much of this is automated:
- A formatter applies the formatting automatically, so nobody argues about spaces or line breaks.
- A linter (static analyzer) detects likely bugs and bad practices; the Definition of Done already required introducing no new warnings.
- The rest (English names for domain concepts, tests with names that describe the behavior) is agreed on and reviewed while pairing.
What matters is that the standard belongs to the team: the team decides it, reviews it in retrospectives, and enforces it in the automated build, not in review discussions.
8.4. Sustainable Pace
The first edition of XP talked about the 40-hour week; the second, about energized work: working only as many hours as you can be productive, at a pace that can be kept up indefinitely. It is the eighth principle of the Agile Manifesto.
- Sustained overtime doesn't make you faster: it increases mistakes, which create more work. The two months of overtime at the end of TaskMaster 1.0 ended with a serious sync bug in the hands of the first customers.
- Overtime is a symptom: of an unrealistic plan, of defects piling up, or of interruptions. You deal with it by looking for the cause, as in the joint retrospective.
- A sustainable pace is also a consequence of the other practices: when defects are caught in minutes rather than in production, the firefighting weeks go away.
- Órbita Adopts XP: Experiment EXP-02
9.1. How It Was Organized
EXP-02 started on Monday, September 7, with Sprint 14. The lesson from the joint retrospective was clear: the technical practices had been postponed because capacity was never set aside for them. This time:
- Explicit capacity in the Sprint Backlog: in the Sprint 14 Sprint Planning, the team set aside about 4 points for the contract tests and for speeding up the build. María accepted this knowing that Release 2 would end on September 18 with somewhat less than planned.
- Training: Sara gave two one-hour sessions on automated testing and TDD (it was item MB-04 in the improvement backlog). The first practice was a kata: a short exercise repeated to learn the technique, as in the martial arts.
- Pairing by default on delicate work: every change to the sync or to the API used by 1.0 is done in pairs; for everything else, the team decides.
- Thursday ensemble session: every Thursday, from 11:00 a.m. to 1:00 p.m., the whole team works as an ensemble on the hardest problem of the week. The first sessions were spent writing characterization tests for the 1.0 sync module and starting to refactor it. Lucía joined two of them from Support.
- Automatic measurement: Ana configured the integration server to record the life of each branch and the duration of each build.
9.2. What It Cost
Not everything was easy, and the Sprint 14 retrospective captured it:
- Luis found full-day pairing exhausting. The team agreed not to exceed about four hours of pairing per person per day.
- The mobile interface turned out to be hard to develop with TDD. They agreed to apply TDD to the logic (rules, sync, validations) and to test the interface with automated acceptance tests and checks on a physical device, as the Definition of Done v1.1 already required.
- The first Sprint was slower: velocity in Sprint 14 dropped to 14 points. That was within the experiment's margin (not falling more than 20% below about 17), but it raised doubts that Diego took to the Review with data.
9.3. The Results
At the Sprint 15 retrospective, on Friday, October 2, the team completed the experiment:
experiment: EXP-02
title: "Daily continuous integration and contract tests between the API and 1.0"
# ... (template fields, unchanged since Sep 2)
result:
escaped_defects: {sprint_14: 2, sprint_15: 1, target: "2 or fewer"}
avg_branch_days: {sprint_14: 1.2, sprint_15: 0.6, baseline: 4.5}
velocity: {sprint_14: 14, sprint_15: 17, guardrail: "no lower than 13.6"}
api_1_0_contract_tests: 31
breaks_in_1_0_caught_before_production: 3
build_duration_minutes: {baseline: 14, final: 9}
decision: consolidate
follow_up_changes:
- "Definition of Done v1.2"
- "integration_agreements.yml becomes permanent"
- "Thursday ensemble session is kept"How to interpret it:
- The hypothesis holds: escaped defects dropped to 2 and 1 (target: 2 or fewer) and branches went from living 4.5 days to a little over half a day. So does the guardrail metric: velocity dipped in Sprint 14 and recovered in Sprint 15.
- The most telling figure is the 3 breaks in 1.0 caught before production by the contract tests. Over the summer, each of them would have been an urgent request for Support and an interruption for Ana or Luis.
- Two Sprints are too few to claim that the change is permanent; that is why the measures stay on the team's board.
EXP-03 was also closed that day: with the rotating on-call duty (Carmen in Sprint 14 and Luis in Sprint 15), interruptions to Developers who weren't on call went from 4 in August to 0 and 1; Support's SLE rose to 83% in September, close to the 85% target; and both Sprint Goals were achieved. It was consolidated, with Ana as the next person on call in Sprint 16.
The Definition of Done was updated to version 1.2:
# Definition of Done - TaskMaster Teams (v1.2, October 2026)
## Changes from v1.1
- [ ] The code is merged into the main branch on the same day the
change was started or, at the latest, the next day. (modified)
- [ ] New or modified business logic has been developed with unit
tests written before the code (TDD). (new)
- [ ] The API-1.0 contract tests pass in continuous integration. (new)
- [ ] Reviewed by another person, or developed in a pair. (modified)- The DoD is versioned and records what changes and why, as recommended in Scrum Artifacts.
- The "merged into the main branch" criterion had existed since v1; v1.2 adds the when, which was what it was missing to mean continuous integration.
Meanwhile, the product kept moving forward: Release 2 ended on September 18 with PB-29 (importing tasks from CSV), and weekly active teams kept growing: 38, 44, and 47 in the first three weeks of September and 52 in the week of September 28. TaskMaster Teams was reaching its success signal before October. At the Review on October 2, Elena Campos summed it up like this: "We got to 50 by delivering more slowly for two weeks, not faster."
Common Mistakes and Tips
- Confusing having a CI server with doing continuous integration. If branches live for days, there is no continuous integration, whatever the tool. Measure the life of your branches.
- Writing the code and then "the TDD tests." That is testing after, not TDD. You must see the test fail first; if you have never seen it red, you don't know whether it is capable of catching a bug.
- Steps that are too big. A TDD cycle that lasts an hour isn't a cycle. If you get stuck, back up and write a smaller test.
- Skipping the refactor step. Without it, TDD produces code that works but deteriorates. The refactor step is mandatory, even if it sometimes takes only a minute.
- Refactoring without tests, or mixing refactoring with new functionality. Wear one hat at a time and run the tests after each small change.
- Mandating pairing all day. It is exhausting. Agree on which tasks you use it for and for how many hours.
- Adopting practices in isolation. Continuous integration without tests, or collective ownership without standards, make things worse. XP practices lean on one another.
- Not setting aside capacity. Technical practices cost something at first. If they have no room in the Sprint Backlog, they will always be postponed, as happened at Órbita until September.
- Tip: start with the practice that attacks your most expensive problem (at Órbita, late integration) and measure its effect with an experiment. It is easier to add practices on top of a proven success.
Exercises
Exercise 1: TDD with pytest
PB-12 (Remove a member or leave the space) includes this rule: a space must always have at least one coordinator; the last one cannot be removed. Members are represented as a dictionary {email: role}, where the role is "coordinator" or "member". Following the red-green-refactor cycle, write at least three tests with pytest (removing a regular member, trying to remove the last coordinator, and removing a coordinator when there is another one) and the remove_member(members, email) function that makes them pass.
Exercise 2: Are They Doing Continuous Integration?
At Viajes Brisa, the fictional travel agency from the previous lesson, the team says it "does continuous integration." This is their data for the last month: branches live 3 days on average; the build takes 40 minutes; the main branch was broken for two days in a row without anyone fixing it; the automated tests cover only the price calculation. Apply the three questions from section 7.1 and the table in 7.2, say whether they are doing continuous integration, and propose three actions in order of priority.
Exercise 3: Solo, Pair, or Ensemble
For each situation on María's team, choose solo, pair, or ensemble work, and justify your choice in one sentence:
- Fixing a piece of web interface text that was badly translated into English.
- Deciding how to represent the permissions of Grupo Alba's spaces in the API, which will affect the web app, mobile, and the import.
- Diagnosing a sync defect that only appears with a device that has been offline for hours.
- Onboarding a new hire to the mobile part of the app.
Solutions
Exercise 1
A reasonable sequence: first the regular member test (red because remove_member doesn't exist; green with a simple members.pop(email)); then the last coordinator test (red because no error is raised; green with the check); finally the two-coordinator test (it should pass right away: if it does, that confirms the condition is correct and not too strict).
# roles.py
class LastCoordinator(ValueError):
"""A space cannot be left without any coordinator."""
def remove_member(members, email):
"""members: dictionary {email: role}, with role "coordinator" or "member"."""
coordinators = [e for e, role in members.items() if role == "coordinator"]
if coordinators == [email]:
raise LastCoordinator("The space needs at least one coordinator")
members.pop(email, None)# test_roles.py
import pytest
from roles import LastCoordinator, remove_member
def test_a_member_can_be_removed():
members = {"[email protected]": "coordinator", "[email protected]": "member"}
remove_member(members, "[email protected]")
assert "[email protected]" not in members
def test_the_last_coordinator_cannot_be_removed():
members = {"[email protected]": "coordinator", "[email protected]": "member"}
with pytest.raises(LastCoordinator):
remove_member(members, "[email protected]")
assert "[email protected]" in members
def test_a_coordinator_can_be_removed_if_there_is_another():
members = {"[email protected]": "coordinator", "[email protected]": "coordinator"}
remove_member(members, "[email protected]")
assert members == {"[email protected]": "coordinator"}- The list comprehension
[e for e, role in members.items() if role == "coordinator"]goes through the dictionary and keeps the email addresses whose role is coordinator. coordinators == [email]is true only if there is one coordinator and it is precisely the person you want to remove.members.pop(email, None)removes the entry; theNoneavoids an error if the email address wasn't there.- When you run
pytest -q, all three tests should pass. A typical mistake: writingif len(coordinators) == 1, which would prevent removing a regular member when there is only one coordinator. A fourth test that checks this would be a good addition.
Exercise 2
- Question 1 (daily integration): no, branches live 3 days.
- Question 2 (tests that give confidence): no, they only cover the price calculation.
- Question 3 (immediate fix): no, the main branch was broken for two days.
Conclusion: they have a CI server, but they aren't doing continuous integration. Actions, in order of priority: 1) agree that a broken build is fixed or reverted within minutes, because without that rule everything else loses its meaning; 2) extend the automated tests to the critical flows (bookings and payments) and speed the build up toward 10 minutes, for example by running tests in parallel; 3) cut branch life down to one day, with feature flags for incomplete work. Measure branch life and the time spent with a broken build before and after, as an experiment.
Exercise 3
- Solo: a simple, well-understood task; a review afterward is enough.
- Ensemble: it is a design decision that affects the whole team; making it together avoids handoffs and misunderstandings.
- Pair (for example, Ana with Lucía, as MB-05 proposed): a complex problem where two sets of eyes catch more, and which also spreads knowledge of the sync.
- Pair, strong-style, with the new person driving and Luis navigating: it is the fastest way to pass on knowledge.
Conclusion
Extreme Programming completes Scrum and Kanban with what they leave unsaid: how to build the software so that changing it stays cheap. Its values (communication, simplicity, feedback, courage, and respect) and its principles guide decisions; its practices, which reinforce each other, make them concrete. Test-driven development designs the code in red-green-refactor cycles of a few minutes; refactoring improves the structure without changing the behavior, protected by the tests; pair and ensemble programming review the code and spread knowledge while the work is being done; continuous integration, with trunk-based development, catches problems within hours rather than at the end of the Sprint; and simple design, collective ownership, coding standards, and sustainable pace keep the team and the code in good shape over the long term. At Órbita, EXP-02 showed with data that setting aside capacity for these practices doesn't slow you down: escaped defects dropped, branches went from living days to hours, and TaskMaster Teams reached its 52 active teams.
Merging daily and having reliable automated tests has a consequence: the code on the main branch is almost always ready to reach users. Yet at Órbita, the move to production was still manual: Javier Soto did it on Thursday afternoons, and it took hours. With the migration finished and new infrastructure in place, the two teams have the chance to shorten that last stretch too. That is what you will see in the next lesson, DevOps and Continuous Delivery in Agile Teams.
