Nexus Learn

Lecture 4: Extreme Programming (XP)

Lecture Notes SE-401 Software Engineering 21 min read Updated 8 Nov 2026

↓ Download notes (Word)

On this page
  1. §1 What is Extreme Programming?
  2. §2 The five XP values
  3. §3 The XP process
  4. §4 User stories
  5. §5 XP planning: the planning game
  6. §6 XP design
  7. §7 XP coding
  8. §8 XP testing and the other practices
  9. §9 Industrial XP and the limits of XP
  10. §10 Worked activity: plan a mini XP release
  11. Summary
  12. Word bank
  13. Self-check questions

How to use these notes: section numbers (§1.1, §1.2 ...) match the question bank. "Slide L04-S07" means slide 7 of this lecture. Difficult words are explained in "Word help" boxes and in the word bank at the end.

Learning outcomes

By the end of this lecture you should be able to:

SLO

Learning outcome

CLO

Bloom

Slides

SLO 4.1

Explain what Extreme Programming (XP) is and state its five values.

CLO1

C2 Understand

L04-S05, S06

SLO 4.2

Describe the four framework activities of the XP process.

CLO1

C2 Understand

L04-S07

SLO 4.3

Write user stories in the role-goal-benefit format with acceptance tests.

CLO1

C3 Apply

L04-S08, S09

SLO 4.4

Explain XP planning: story value and cost, ordering stories, and project velocity.

CLO1

C2 Understand

L04-S10

SLO 4.5

Explain the key XP practices: simple design, CRC cards, spike solutions, refactoring, test-first, pair programming and continuous integration.

CLO1

C2 Understand

L04-S11 to S15

SLO 4.6

Describe Industrial XP and discuss the limits of XP.

CLO1

C2 Understand

L04-S16

In Lecture 3 you learned the values of agile development. Today we study the first real agile method: Extreme Programming (XP). XP turns the agile values into daily practices that programmers actually follow. You will also learn to write proper user stories, which you use on your Trello board in Practical 2.

§1 What is Extreme Programming?

Slides L04-S02, L04-S05

§1.1 Recap: from values to methods

Slide L04-S02

Lecture 3 gave us the four values of the Agile Manifesto (individuals and interactions, working software, customer collaboration, responding to change) and twelve principles. Values tell us what matters. A method tells us what to do on Monday morning. XP is one such method; Scrum (Lecture 5) and Kanban (Lecture 6) are others.

§1.2 Where XP came from

Slide L04-S05

Kent Beck developed XP in the late 1990s while leading a payroll project at Chrysler (the C3 project, 1996). He described it in the book *Extreme Programming Explained* (1999; 2nd edition 2004). XP is one of the methods whose authors signed the Agile Manifesto in 2001.

Why "extreme"? XP takes practices that everyone agrees are good, and pushes them to the extreme:

If this is good ...

... XP does it all the time

Code reviews are good

Pair programming: code is reviewed every minute by a second programmer

Testing is good

Test-first: tests are written before the code, and run many times a day

Customer feedback is good

An on-site customer sits with the team; small releases every few weeks

Simple design is good

Design only for today's stories; clean up continuously (refactoring)

Integration is good

Continuous integration: join and test everyone's code many times a day

XP is best known for small teams (about 2-12 people) building software whose requirements change often.

Word help

extreme = taken as far as it can go

method = a defined way of doing a job, with steps and practices

§2 The five XP values

Slides L04-S06

§2.1 Communication, simplicity, feedback, courage, respect

Slide L04-S06

Beck says every XP practice grows from five values (Pressman, section 5.4.1):

Value

Meaning in XP

Example

Communication

Close, informal, often spoken collaboration between customers and developers; no long documents as the main channel.

The canteen manager sits with the team for an hour each day to answer questions.

Simplicity

Design only for immediate needs, not for guesses about the future. Simple code is easier to understand and change.

Build a simple menu list now; do not build a "multi-restaurant franchise" system nobody asked for.

Feedback

Get feedback from three sources: the software itself (tests), the customer (acceptance tests, releases) and the team (estimates).

Unit tests run in seconds and tell the programmer at once if something broke.

Courage

The discipline to do the right thing: to design for today, to throw away bad code, to tell the customer the truth about the schedule.

Telling the client: "Payment will not be ready this release; here is what will be."

Respect

Team members respect each other, the customer and the work. Respect grows as the team delivers working increments.

No blaming the person who broke a test; the pair fixes it together.

Exam tip

Learn the five values as a list: C-S-F-C-R (Communication, Simplicity, Feedback, Courage, Respect). A common mistake is to mix them with the four Agile Manifesto values.

Word help

courage = being brave enough to do the right thing even when it is hard

feedback = information about how well something worked, used to improve it

§3 The XP process

Slides L04-S07

§3.1 Four framework activities

Slide L04-S07

Pressman describes XP as an object-oriented approach that uses four framework activities, repeated for every release:

Activity

Key practices

What comes out

1. Planning

Listening, user stories, value and cost, release plan, project velocity

Ordered stories for the next release

2. Design

Keep it simple (KIS), CRC cards, spike solutions, refactoring

Simple design; prototypes for hard parts

3. Coding

Unit tests written first, pair programming, continuous integration

Working, tested code

4. Testing

Automated unit tests, regression testing, acceptance (customer) tests

A software increment the customer accepts

After testing, the increment is released and project velocity is calculated. Then the cycle starts again with the next release. One cycle is short: a release every few weeks to a few months, with iterations of 1-3 weeks inside it.

Real-world example: a chai dhaba's daily cycle

Morning: decide today's menu (planning). Arrange the stove and pots in the simplest way (design).

Cook, with one person cooking and one tasting (coding with a pair). Customers taste and say "more sugar" (acceptance testing).

Tomorrow's plan uses today's feedback. XP works the same way, release after release.

§4 User stories

Slides L04-S08 to L04-S09

§4.1 The user story format

Slide L04-S08

In XP, planning starts with listening. The customer describes the needed features as user stories. Each story is written on an index card (today: a Trello or Jira card). The most widely used format is:

Part

Question it answers

Example

As a <role>

Who needs this?

As a student

I want <goal>

What do they want to do?

I want to pre-order my lunch

so that <benefit>

Why does it matter?

so that I do not miss my next class waiting in the queue

A story card is only a reminder. Ron Jeffries (another XP founder) described a good story with three Cs:

C

Meaning

Card

A short written description, small enough to fit on an index card.

Conversation

The details come from talking with the customer, not from writing more on the card.

Confirmation

Acceptance tests that confirm when the story is done.

Acceptance tests are written with the customer for each story. In Practical 2 you call them acceptance criteria. Example for the pre-order story: (1) the student sees an order number and pickup time after ordering; (2) the order appears in the kitchen list within 5 seconds; (3) an empty cart cannot be ordered.

Word help

role = the type of user, such as student, cashier or admin

benefit = the reason the user wants it; the value they get

§4.2 Good and bad stories

Slide L04-S09

A useful checklist for good stories is INVEST: Independent, Negotiable, Valuable, Estimable, Small, Testable. The four checks students miss most are:

Check

Bad story

Better story

Valuable (a user need, not a task)

"Create the orders table in MySQL."

"As a student, I want my order saved so that I can check it later." (The table is a task inside this story.)

Testable

"As a user, I want the app to be fast."

"As a student, I want the menu to open within 2 seconds on mobile data so that I can order between classes."

Small

"As a student, I want to order, pay, track and rate my food."

Four separate stories: order; pay; track; rate.

Real role and benefit

"As a developer, I want to use React."

Not a story: technology is the team's decision. Write the user need instead.

Quick check from the slide: "As an admin, I want a report" is missing a benefit and is too vague to test. Better: "As the canteen owner, I want a daily sales total so that I can order the right amount of rice for tomorrow."

Word help

INVEST = a checklist for good stories: Independent, Negotiable, Valuable, Estimable, Small, Testable

estimable = clear enough that the team can guess its size

§5 XP planning: the planning game

Slides L04-S10

§5.1 Value, cost and the release plan

Slide L04-S10

1. The customer writes stories and gives each a value (priority) based on business need.

2. The XP team estimates each story's cost, measured in development weeks. If a story needs more than 3 weeks, the customer is asked to split it.

3. Customer and team group stories into the next release (the next increment) and agree on a delivery date.

4. New stories can be added at any time; the customer can change values, split stories or remove them.

Pressman gives three ways to order the stories in a release:

Order

When it is sensible

All stories in the release implemented at once (within a few weeks)

Small release where every story is needed together

Highest-value stories first

The customer wants the most useful features as early as possible

Riskiest stories first

A story is technically uncertain (e.g. a new payment API) and failure would change the whole plan

Project velocity is the number of customer stories (or story points) implemented during the first release. After that, velocity is used to (1) estimate delivery dates for later releases and (2) check for overcommitment: if the plan needs more than the velocity, the team changes the plan, not its working hours.

Real-world example: velocity like a bowler's economy rate

A bowler who gave away 6, 7 and 5 runs in his last three overs has an average of 6 runs an over. The captain plans the next overs with that number, not with hope.

A team that finished 18, 22 and 20 story points in three iterations has a velocity of 20. It plans 20 points, not 30.

Word help

velocity = how much work a team really finishes in one iteration, on average

overcommitment = promising more work than the team can finish

§6 XP design

Slides L04-S11

§6.1 Keep it simple, CRC cards, spike solutions, refactoring

Slide L04-S11

Practice

Meaning

Example

Keep it simple (KIS)

Design only for the stories in this release. Do not add features or structure for guessed future needs.

A single-canteen menu table now, not a franchise system.

CRC cards

Class-Responsibility-Collaborator cards: one card per class, listing what it is responsible for and which classes it works with. In XP they are the only design work product.

Order | responsibilities: hold items, compute total | collaborators: MenuItem, Payment

Spike solution

When a design problem is hard, build a quick operational prototype of only that part to reduce risk, then throw it away or improve it.

One day testing the JazzCash sandbox API before promising online payment.

Refactoring

Changing the code's internal structure to improve it without changing what it does (its external behaviour).

Renaming x1 to order_total; removing copied code into one function.

In XP, design is not a phase that ends. It happens before and during coding, and refactoring keeps the design clean as the system grows. This is how XP fights the "house that grows without a plan" problem from Lecture 2.

Real-world example: cleaning the kitchen while cooking

A good cook wipes the counter and washes pots between dishes. The meal is the same, but the kitchen stays usable.

Refactoring is the same: the software does the same thing, but the code stays easy to change.

Word help

prototype = a quick early sample built to learn something

responsibility = a job a class must do or something it must know

§7 XP coding

Slides L04-S12 to L04-S13

§7.1 Test-first development

Slide L04-S12

Before writing code for a story, the programmer writes unit tests that the code must pass. Then they write just enough code to pass them. Students call this "red, green, clean":

1. Red: write a test; run it; it fails (the code does not exist yet).

2. Green: write the simplest code that makes the test pass.

3. Clean: refactor the code; run the tests again to prove nothing broke.

Worked example (Python, pytest). Story: "As a student, I want 10% off when I show my student card on orders of Rs 500 or more." The tests come first:

test_order.py (written FIRST)

from order import order_total

def test_total_without_card():

assert order_total([150, 200]) == 350

def test_discount_at_500_or_more():

assert order_total([300, 200], student_card=True) == 450

def test_no_discount_below_500():

assert order_total([300, 100], student_card=True) == 400

order.py (written SECOND, just enough to pass)

def order_total(prices, student_card=False):

total = sum(prices)

if student_card and total >= 500:

total = total * 90 // 100 # 10% off

return total

With an empty function the real pytest run printed 3 failed in 0.02s (red). With the code above it printed 3 passed in 0.01s (green). The tests also say exactly what "done" means, before any code exists.

Real-world example: the tailor measures first

A tailor takes your measurements before cutting the cloth. The measurements are the test the suit must pass. Cutting first and measuring later wastes cloth.

Word help

unit test = a small automatic test of one piece of code, such as one function

pytest = a popular Python tool that finds and runs unit tests

§7.2 Pair programming

Slide L04-S13

In XP, two programmers work together at one computer to write the code. They swap roles often:

Role

What they do

Driver

Has the keyboard; types the code; thinks about the current line.

Navigator

Reviews every line as it is typed; thinks about the bigger picture: the design, the tests, the next step, mistakes.

Benefits

Costs and limits

Code is reviewed in real time, so many errors are caught at once

Two people on one task can look like double cost to managers

Knowledge spreads: more than one person understands each part (collective ownership)

Pairs that do not get along, or one person who takes over, waste time

Encourages refactoring and keeps the pair focused

Tiring if done all day; teams usually pair for part of the day

New team members learn quickly from experienced ones

Hard when team members work from different places without good tools

Studies of pair programming show mixed results: pairs often produce fewer defects, but the total effort is not always lower. It works best on hard or important code and for teaching newcomers.

Real-world example: two people on a motorcycle in a new city

One rides (the driver); the one behind reads Google Maps and watches for turns (the navigator). They reach the right place faster and with fewer wrong turns than one rider stopping to check his phone.

Word help

driver = the person typing the code

navigator = the person checking the code and thinking ahead

§8 XP testing and the other practices

Slides L04-S14 to L04-S15

§8.1 Unit tests, continuous integration and acceptance tests

Slide L04-S14

Kind of test

Who writes it

Purpose

Unit tests

Programmers, before the code

Check each small piece. They are automated, so they can be run again after every change (regression testing).

Continuous integration (CI)

The team, with a tool (e.g. GitHub Actions)

Join every pair's code into the main version several times a day and run all tests automatically, so problems are found within hours, not weeks.

Acceptance tests (customer tests)

The customer, with the team

Check whole features that the customer can see, based on the user stories. A story is done when its acceptance tests pass.

Because unit tests are automated, every change is checked against all earlier tests. This is what makes XP's frequent changes and refactoring safe, and it is why Lecture 3 said good practices flatten the cost-of-change curve.

Word help

regression testing = running old tests again to check a change did not break something that used to work

integration = joining separate pieces of code into one working system

§8.2 Other XP practices

Slide L04-S15

Sommerville lists the practices of XP. Besides those above, five more complete the picture:

Practice

Meaning

Example

Small releases

Release the smallest useful set of features first, then add to it in frequent releases.

Food delivery apps update every two weeks.

Collective ownership

Any pair can change any part of the code; no one "owns" a module alone.

If the person who wrote the payment code is sick, the team can still fix it.

Sustainable pace

No large amounts of overtime; tired people make mistakes.

A 40-hour week instead of all-night coding before each release.

On-site customer

A customer representative works with the team full time and answers questions immediately.

The canteen manager is available in the team room.

Incremental planning

Requirements are user story cards; the team decides which go into the next release.

The planning game on slide 10.

Together with simple design, test-first, refactoring, pair programming and continuous integration, these make the ten XP practices in Sommerville's list.

§9 Industrial XP and the limits of XP

Slides L04-S16

§9.1 Industrial XP (IXP)

Slide L04-S16

Joshua Kerievsky described Industrial XP as XP adapted for larger organizations. It keeps XP's spirit and adds six new practices:

IXP practice

Meaning

Readiness assessment

Check before starting that the organization is ready: right people, support from management, a suitable environment.

Project community

The right people with the right skills, including people outside the core team (users, managers, operations).

Project chartering

Check that the project fits the organization's business goals and does not harm other projects.

Test-driven management

Measure progress with clear, testable "destinations" and checkpoints.

Retrospectives

After each increment, a special review meeting to learn from problems and improve.

Continuous learning

Team members are encouraged to keep learning new methods and techniques.

§9.2 The XP debate: where XP struggles

Slide L04-S16

Criticism

Why it matters

Requirements volatility

Because the customer can change stories at any time, the project can keep growing and work may be redone.

Conflicting customer needs

Many customers or departments may want different things; one on-site customer cannot speak for all.

Informal requirements

Story cards and conversation can miss details, contradictions or safety rules that a written specification would catch.

Little formal design

For large or complex systems, the lack of an overall architecture can cause problems later.

XP supporters reply that frequent releases, tests and refactoring catch most of these problems early. As in Lectures 2 and 3: choose the method that fits the project. XP fits small, co-located teams with an available customer and changing requirements.

Word help

volatility = how quickly and often something changes

retrospective = a meeting that looks back at how the work went, to improve it

§10 Worked activity: plan a mini XP release

Slides L04-S17

§10.1 The task

Slide L04-S17

In groups (9 minutes), for the UAF cafeteria pre-order app: (1) write three user stories in the full format; (2) give each one acceptance test; (3) estimate each in development weeks; (4) choose an order for the release (value first or risk first) and say why; (5) name one XP practice you would use for the hardest story.

§10.2 A model answer

Slide L04-S17

Story

Acceptance test

Cost

As a student, I want to see today's menu with prices so that I can decide quickly.

All items show name and price in rupees; sold-out items are greyed out.

1 week

As a student, I want to pre-order my lunch so that I do not wait in the queue.

After ordering I see an order number and pickup time; the kitchen sees the order within 5 seconds.

2 weeks

As a student, I want to pay with JazzCash or Easypaisa so that I do not need cash.

A successful payment marks the order "Paid"; a failed payment leaves it "Unpaid" and shows a message.

3 weeks

Order: riskiest first is reasonable for payment, because it depends on an outside API; a spike solution (one day with the payment sandbox) reduces that risk. Value first is also correct: menu and pre-order give students something useful in the first two weeks, with cash payment at the counter. Practice for the hardest story: a spike solution, test-first unit tests for payment states, or pair programming. Accept other reasoned answers.

Summary

  • XP is an agile method developed by Kent Beck (late 1990s) that takes good practices "to the extreme".
  • Five XP values: communication, simplicity, feedback, courage, respect.
  • Four framework activities: planning, design, coding, testing, repeated every release.
  • User stories: As a <role>, I want <goal> so that <benefit>; three Cs: card, conversation, confirmation (acceptance tests).
  • Planning: customer gives value, team gives cost in weeks (split if more than 3); order by all-at-once, value or risk; project velocity sets later plans.
  • Design: KIS, CRC cards, spike solutions, refactoring. Coding: unit tests first, pair programming, continuous integration.
  • Testing: automated unit tests (regression) and customer acceptance tests.
  • Industrial XP adds six practices for larger organizations. XP struggles with very large, safety-critical or multi-customer projects.
  • Before Lecture 5: read Pressman 5.5 or Sommerville 3.3 (Scrum); add acceptance criteria to every Sprint 1 card on your Trello board; Quiz 1 in week 4 covers L1-L6.

Word bank

Word

Simple meaning

Example

Extreme Programming (XP)

an agile method that pushes good practices to the extreme

pair programming and tests written before code

value (XP)

one of five ideas XP is built on

communication, simplicity, feedback, courage, respect

user story

a short description of a feature from the user's point of view

As a student, I want to pre-order lunch so that...

acceptance test

a customer test that confirms a story is done

the order appears in the kitchen within 5 seconds

three Cs

card, conversation, confirmation

a story card, the talk with the customer, its tests

INVEST

checklist for good stories

Independent, Negotiable, Valuable, Estimable, Small, Testable

release

a version of the software given to users

release 1: menu and pre-order

project velocity

stories or points finished in one release or iteration

20 points per iteration

KIS

keep it simple: design only for today's needs

a single-canteen menu, not a franchise system

CRC card

class-responsibility-collaborator card used for design

Order: compute total; works with MenuItem

spike solution

a quick prototype to test a hard design problem

one day trying the JazzCash sandbox

refactoring

improving code structure without changing what it does

renaming x1 to order_total

test-first

writing unit tests before writing the code

test_discount_at_500_or_more written first

pair programming

two programmers, one computer: driver and navigator

one types, one reviews

continuous integration

joining and testing everyone's code many times a day

tests run on every GitHub push

regression test

running old tests again after a change

all 3 order tests run after every edit

collective ownership

anyone in the team can change any code

any pair can fix the payment module

Industrial XP

XP adapted for large organizations, with six extra practices

readiness assessment, retrospectives

Self-check questions

Try each question without looking. Then check your answer in the section shown.

#

Question

See

1

Who developed XP, and why is it called "extreme"?

§1.2

2

List the five XP values and give an example of courage.

§2.1

3

Name the four framework activities of XP and one practice in each.

§3.1

4

Write a user story for your team project in the full format, with one acceptance test.

§4.1

5

What are the three Cs of a user story?

§4.1

6

What is wrong with "As a user, I want the app to be fast"? Rewrite it.

§4.2

7

In XP planning, who gives the value of a story and who gives its cost? What happens if a story costs more than 3 weeks?

§5.1

8

Give Pressman's three ways of ordering the stories in a release.

§5.1

9

What is project velocity, and what two things is it used for?

§5.1

10

What is a CRC card? What is a spike solution?

§6.1

11

Explain red, green, clean with the order_total example.

§7.1

12

Explain the roles in pair programming and give two benefits and two costs.

§7.2

13

Differentiate between unit tests and acceptance tests in XP.

§8.1

14

Name the six new practices of Industrial XP.

§9.1

15

Give two criticisms of XP.

§9.2

Further reading

  • Pressman & Maxim, *Software Engineering: A Practitioner's Approach*, 8th ed., Chapter 5, section 5.4 (Extreme Programming).
  • Sommerville, *Software Engineering*, 10th ed., Chapter 3, section 3.2 (Agile development techniques).
  • Look ahead: Pressman 5.5 / Sommerville 3.3 (Scrum) for Lecture 5.

← All SE-401 material