Extreme Programming and Lean
Last updated
Scrum says how to organise a team's work but nothing about how to write the code. Extreme Programming fills that gap with engineering practices that support each other. Lean, borrowed from Toyota's factories, gives a way of seeing waste. In this lesson you'll meet both, and look at what research says about one of XP's most argued-over practices.
By the end of this lesson you can
- Name the main XP practices and how they support each other
- Name Lean’s seven wastes of software and spot them
- Say what research found about pair programming
Extreme Programming
Extreme Programming (XP) was developed by Kent Beck and colleagues in the late 1990s, and set out in his book Extreme Programming Explained (1999; second edition, with Cynthia Andres, 2004). The name comes from taking good practices to the extreme: if code review is good, review all the time (pair programming); if testing is good, test all the time (test-first, automated); if short cycles are good, make them very short.
Among XP's practices:
- Test-first programming: write an automated test before the code that makes it pass (lesson 6.6 teaches it).
- Pair programming: two people at one computer, one typing, one thinking ahead; they swap often.
- Continuous integration: join everyone's changes and run all the tests many times a day (Stage 7).
- Refactoring and incremental design: improve the code's structure a little every day, instead of designing everything up front.
- Small releases and short cycles: working software every week or two.
- A sustainable pace: work hours you could keep up for years. Beck's first edition called it the forty-hour week.
- The whole team together, customer included, sitting where they can talk.
As a UML activity diagram, an XP iteration is loops inside loops: test and code every few minutes, the customer’s acceptance every story, a release every iteration.
Press Walk through it to follow the work round the chart, one stop at a time.
- User stories from the customer, then plan the iteration.
- In pairs: write a failing test, then write just enough code to pass it.
- All tests pass? If not, back to the code (a loop back). If so, refactor, then integrate.
- Customer accepts it? If not, back to the next test (a loop back). If so, a small release, and the next stories start again (a loop back).
Practices that turn each other
XP's practices aren't a menu; they support each other, like gears. Choose one to see what it drives:
Test-first drives Refactoring. Tests written first mean the code can be reshaped safely: if a change breaks something, a test says so at once.
Take one gear out and the others slip. Refactoring without tests is risky; small releases without continuous integration break things; test-first without refactoring leaves messy code. Many teams take a few XP practices into Scrum, which is how most people meet them today.
Lean: see the waste
Lean comes from Toyota's production system (lesson 2.7). In Lean Software Development (2003), Mary and Tom Poppendieck translated it into seven principles for software: eliminate waste, amplify learning, decide as late as possible, deliver as fast as possible, empower the team, build integrity in, and see the whole.
Waste is anything that takes effort without adding value for the people the software is for. They listed seven wastes of software, each matching one of Toyota's factory wastes:
| Waste | In software |
|---|---|
| Partially done work | Code not finished, not tested or not released: cost with no value yet |
| Extra processes | Paperwork and steps that nobody uses |
| Extra features | Features nobody needs, which still have to be tested and maintained |
| Task switching | People split across too many things at once |
| Waiting | Work held up for approvals, decisions or other people |
| Motion | Time spent finding people, answers or documents |
| Defects | Bugs, and the rework they cause, costing more the later they’re found |
Lesson 2.7's WIP limits attack two of them: partially done work and task switching.
Spot the waste at Pila
Which waste is each situation?
0 of 7 placed right
Four features are each 80% finished; none can be used.
The finished SMS feature waits nine days for the barangay IT officer to sign it off.
Marco works on three features in one morning, switching every hour.
A monthly 20-page report nobody reads is written for the council.
The team builds a dark mode nobody asked for.
Rina has to drive to the health centre to ask Ate Cora each question, because there’s no other way to reach her.
A bug in the queue numbers is found by patients, and fixing it takes a week of rework.
Spot the trap: "pair programming halves the work done"
Kap. Ernesto sees Marco and Rina at one computer. “I’m paying for two people and getting one person’s work. Split them up.”
What happens if…
Check what you learned
Sources
Every claim on this page comes from these sources: the standard, the founding text of a method, a study, or the official record of a project, from the body that publishes it. Industry reports are labelled as such.
- Kent Beck with Cynthia Andres, Extreme Programming Explained: Embrace Change, 2nd edition (2004): XP’s values, principles and practices
- Mary and Tom Poppendieck, Lean Software Development: An Agile Toolkit (2003): the seven principles and the seven wastes of software
- Hannay, Dybå, Arisholm and Sjøberg, “The effectiveness of pair programming: A meta-analysis”, Information and Software Technology (2009): what dozens of studies of pair programming found, taken together