Slide 2
Last lecture in one minute
Individuals and interactions
Working software
Customer collaboration
Responding to change
over processes and tools
over comprehensive documentation
over contract negotiation
over following a plan
Exit ticket check: "Customer collaboration." is not an answer. "Customer collaboration, because only the canteen staff know how orders really flow" is. Always give the reason.
Today: values tell us what matters. A METHOD tells us what to do every day. XP is our first agile method.
SE Lecture 4
Recap
Sheet 02 of 20
Slide 3
By the end of today, you will be able to
Explain what XP is and state its five values
Describe the four activities of the XP process
Write user stories with acceptance tests
Explain XP planning: value, cost and velocity
Explain XP practices: test-first, pairs, refactoring and more
Describe Industrial XP and the limits of XP
SE Lecture 4
Objectives
Sheet 03 of 20
Slide 4
Today's plan: 60 minutes
0-6 min
Welcome, recap, objectives
This week
6-17 min
What XP is, five values, the XP process
- Practical 2: your product backlog on a Trello Scrum board
- Today's user stories go straight onto those cards
- Next: Lecture 5, Scrum
17-25 min
User stories: format, good and bad
25-30 min
XP planning and velocity
30-40 min
Design, test-first, pair programming
40-46 min
Testing, other practices, Industrial XP
46-55 min
Group activity: plan a mini XP release
55-60 min
Key points, homework, exit ticket
SE Lecture 4
Plan
Sheet 04 of 20
Slide 5
What is Extreme Programming?
- Kent Beck
- Developed XP in the late 1990s on a payroll project at Chrysler (1996). Book: Extreme Programming Explained (1999).
Why "extreme"? Take a good practice and do it all the time:
Code reviews are good
→
Pair programming: review every minute
Testing is good
→
Write tests before the code
A method for small teams (about 2-12 people) whose requirements change often.
Customer feedback is good
→
On-site customer, small releases
Word help
extreme = taken as far as it can go
Simple design is good
→
Design for today; refactor always
Word help
method = a defined way of doing a job
Integration is good
→
Integrate many times a day
SE Lecture 4
What is XP
Sheet 05 of 20
Slide 6
The five XP values
Communication
Simplicity
Feedback
Courage
Respect
Talk often and informally with customers and team
Design only for today's needs
From tests, from the customer, from the team
Do the right thing, even when it is hard
For each other, the customer and the work
Courage example: telling the client, "Online payment will not be ready this release. Here is what will be ready." Not hiding the problem until the deadline.
Exam tip: C-S-F-C-R. Do not mix these five with the four Agile Manifesto values.
SE Lecture 4
XP values
Sheet 06 of 20
Slide 7
The XP process: four activities, every release
1. Planning
→
2. Design
→
3. Coding
→
4. Testing
User stories, value and cost, velocity
Keep it simple, CRC cards, spikes, refactoring
Tests first, pair programming, continuous integration
Automated unit tests, acceptance tests
Release the increment → measure project velocity → plan the next release
Real-world example: a chai dhaba's day
Plan today's menu, set up the stove simply, cook with one cooking and one tasting, customers say "more sugar", tomorrow's plan uses it.
SE Lecture 4
XP process
Sheet 07 of 20
Slide 8
User stories: the format
As a <role>
who needs it?
student
I want <goal>
what do they want to do?
to pre-order my lunch
so that <benefit>
why does it matter?
I do not miss my next class in the queue
Three Cs (Ron Jeffries)
Card
Conversation
Confirmation
Short enough for an index card (or a Trello card)
Details come from talking with the customer
Acceptance tests say when it is done
Word help
acceptance test = a customer test that confirms a story is done, e.g. "the order appears in the kitchen within 5 seconds"
SE Lecture 4
User stories
Sheet 08 of 20
Slide 9
Good and bad stories
"Create the orders table in MySQL."
A task, not a user need
- INVEST
- Independent
- Negotiable
- Valuable
- Estimable
- Small
- Testable
"As a user, I want the app to be fast."
Cannot be tested; who is "user"?
"As a student, I want to order, pay, track and rate my food."
Too big: four stories in one
"As a developer, I want to use React."
No user value; a tech choice
Quick check: fix "As an admin, I want a report." → As the canteen owner, I want a daily sales total so that I can order the right amount of rice for tomorrow.
SE Lecture 4
User stories
Sheet 09 of 20
Slide 10
XP planning: the planning game
Customer
Writes stories and gives each a VALUE (priority)
- Project velocity = stories (or points) finished in the first release. Then used to:
- estimate delivery dates
- spot overcommitment
XP team
Gives each story a COST in development weeks. More than 3 weeks? Split it.
Together
Group stories into the next release and agree a date
Real-world example: a bowler's economy
Three ways to order a release (Pressman)
- 6, 7 and 5 runs in three overs: plan with about 6 an over, not with hope.
- A team that finished 18, 22 and 20 points plans 20, not 30.
- All at once, within a few weeks
- Highest value first
- Riskiest first
SE Lecture 4
Planning
Sheet 10 of 20
Slide 11
XP design: keep it simple
Class: Order
Keep it simple (KIS)
CRC cards
- Responsibilities
- hold items
- compute total
- know its status
- Collaborators
- MenuItem
- Payment
- KitchenQueue
Design only for this release's stories. No guessed future features.
Class · Responsibilities · Collaborators. The only design document in XP.
Spike solution
Refactoring
Refactoring = cleaning while cooking
A quick prototype of a hard part, to reduce risk. E.g. one day with the JazzCash sandbox.
Improve the code's structure WITHOUT changing what it does.
Wipe the counter between dishes. The meal is the same; the kitchen stays usable.
SE Lecture 4
Design
Sheet 11 of 20
Slide 12
XP coding: write the test first
Story: 10% off with a student card on orders of Rs 500 or more.
test_order.py (written FIRST)
order.py (written SECOND)
- 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
- def order_total(prices, student_card=False):
- total = sum(prices)
- if student_card and total >= 500:
- total = total * 90 // 100
- return total
RED
Empty function: 3 failed in 0.02s
GREEN
Real function: 3 passed in 0.01s
CLEAN
Refactor, run tests again
Real-world example: a tailor takes your measurements (the test) before cutting the cloth (the code).
Word help
unit test = an automatic test of one small piece of code
SE Lecture 4
Coding
Sheet 12 of 20
Slide 13
Pair programming: two people, one computer
Real-world example: a motorcycle in a new city
- Driver
- types the code; thinks about this line
- Navigator
- reviews each line; thinks ahead
- One rides. The one behind reads Google Maps and watches for the turn.
- They arrive faster, with fewer wrong turns, than one rider stopping to check his phone.
Swap roles often.
- Benefits
- Errors caught as they are typed
- Knowledge spreads in the team
- Encourages refactoring and focus
- Newcomers learn fast
- Costs and limits
- Looks like double cost to managers
- Clashing pairs waste time
- Tiring all day
- Hard for remote teams
Be honest: research shows pairs often make fewer defects, but total effort is not always lower. Pairing works best on hard code and for teaching newcomers.
SE Lecture 4
Coding
Sheet 13 of 20
Slide 14
XP testing: three kinds of checks
Unit tests
Continuous integration
Acceptance tests
Written by programmers BEFORE the code. Automated, so they run again after every change (regression testing).
Join every pair's code into the main version several times a day; run all tests automatically (e.g. GitHub Actions).
Written by the customer with the team, from the user stories. A story is done when they pass.
Why it matters: automated tests make frequent change and refactoring safe. This is how XP flattens the cost-of-change curve (Lecture 3).
Word help
regression testing = running old tests again to check that a change broke nothing integration = joining pieces of code into one system
SE Lecture 4
Testing
Sheet 14 of 20
Slide 15
The ten XP practices (Sommerville)
Incremental planning
Story cards; team picks the next release
Small releases
Smallest useful set first, then frequent releases
Simple design
Only enough for today's stories
Test-first development
Unit tests before code
Refactoring
Keep the code clean, all the time
Pair programming
Two people, one computer
Collective ownership
Any pair can change any code
Continuous integration
Integrate and test many times a day
Sustainable pace
No large amounts of overtime
On-site customer
A customer representative works with the team
Dark cards: the practices not covered on earlier slides. Example of sustainable pace: no all-night coding before every release.
SE Lecture 4
Practices
Sheet 15 of 20
Slide 16
Industrial XP, and where XP struggles
Industrial XP (Kerievsky): XP for larger organizations, with six new practices
The XP debate
- Requirements volatility: the project keeps growing
- Conflicting customer needs: one on-site customer cannot speak for all
- Informal requirements: cards can miss details and safety rules
- Little formal design: risky for large systems
Readiness assessment
Is the organization ready?
Project community
The right people, inside and outside the team
Project chartering
Does it fit business goals?
Test-driven management
Measure progress with testable checkpoints
Retrospectives
Review after each increment
Continuous learning
Keep learning new methods
Choose the method that fits.
SE Lecture 4
Industrial XP
Sheet 16 of 20
Slide 17
Activity: plan a mini XP release
UAF cafeteria pre-order app. In your project teams:
Write 3 user stories in the full format
Give each story one acceptance test
Estimate each in development weeks (split if more than 3)
minutes
Choose an order: value first or risk first? Why?
- 6 min in teams
- 3 min to share
Name one XP practice for the hardest story
SE Lecture 4
Activity
Sheet 17 of 20
Slide 18
Key points to remember
XP (Kent Beck, late 1990s) takes good practices to the extreme.
Five values: communication, simplicity, feedback, courage, respect.
Four activities, every release: planning, design, coding, testing.
User story: As a <role>, I want <goal> so that <benefit>; with acceptance tests.
Customer gives value, team gives cost; velocity guides the next release.
Test-first, pair programming, refactoring and continuous integration keep change safe.
Industrial XP adds six practices for big organizations; XP fits small teams best.
SE Lecture 4
Wrap-up
Sheet 18 of 20
Slide 19
Before the next lecture
Read
On your Trello board (team)
- Revise: Pressman 5.4 or Sommerville 3.2 (XP).
- Next: Pressman 5.5 or Sommerville 3.3 (Scrum).
- Every Sprint 1 card has 2-4 testable acceptance criteria
- Every card is a real user story: role, goal, benefit
- Split any story bigger than 13 points
- Bring the board link to Lecture 5
Quiz 1
Week 4. Covers Lectures 1-6: process models, agile, XP, Scrum, other agile models.
SE Lecture 4
Homework
Sheet 19 of 20
Slide 20
Exit ticket
On a small piece of paper, with your name and roll number:
Write ONE user story for your team project in the full format, with ONE acceptance test.
One question you still have after today.
Questions?
SE Lecture 4
Exit ticket
Sheet 20 of 20