Chapter 11 of 32

Kanban & Extreme Programming

In Agile Methodology we saw the values and principles that all agile methods share, and in Scrum we studied the most popular agile framework, with its sprints, roles and events. But Scrum is not the only way to be agile. Two other approaches show up again and again in university exams, interviews and real teams:

  • Kanban, which is all about flow: making work visible, limiting how much is in progress at once, and finishing things faster.

  • Extreme Programming (XP), which is all about engineering discipline: pair programming, test-driven development, continuous integration, refactoring and small releases.

They answer different questions. Kanban asks "how does work move through our team, and where does it get stuck?" XP asks "how do we write code so that change stays cheap?" That is why many teams use them together, often alongside Scrum.


Part 1: Kanban

Where the idea came from

Kanban is a Japanese word meaning roughly "signboard" or "visual card". In the Toyota Production System (developed by Taiichi Ohno and others from the late 1940s onwards), cards were used to signal when a station needed more parts. A station did not produce parts just because it could; it produced only when the next station pulled by sending a card. This kept inventory small and exposed bottlenecks quickly.

In the 2000s, David J. Anderson and others adapted these ideas to software and knowledge work. His 2010 book on Kanban made the approach widely known. Today there are two well-known descriptions:

  • The Kanban Method (Kanban University), with its principles and six general practices.

  • The Kanban Guide by Daniel Vacanti and John Coleman (latest edition May 2025), a short guide that defines Kanban as a strategy for optimizing the flow of value through a process.

Kanban is a method for managing knowledge work by visualizing the workflow, limiting work in progress (WIP), and actively managing and improving the flow of work items from start to finish. Work is pulled into a stage only when there is capacity for it.

Push vs pull: the core intuition

Imagine a college canteen with one cook. If the cashier keeps taking orders and pushing slips to the kitchen, the slips pile up. Every order waits longer, the cook keeps switching between half-made dishes, and nobody gets food quickly. If instead the kitchen takes a new slip only when a burner is free, each order is finished sooner, and the pile of waiting slips tells the manager exactly where the problem is.

Push systemPull system (Kanban)
Work is assigned as soon as it arrivesWork is taken only when someone has capacity
Many items started, few finishedFew items in progress, finished faster
Hidden queues and frequent multitaskingQueues are visible on the board
Bottlenecks are discovered lateBottlenecks show up immediately as full columns

The Kanban Board

The most visible part of Kanban is the board. Each column is a stage of the workflow, each card is one work item (a feature, bug or task), and the number in the column heading is that column's WIP limit.

+-----------+-------------+-----------------+-------------+-----------+
|  Backlog  | Ready (3)   | In Progress (3) | Review (2)  |   Done    |
+-----------+-------------+-----------------+-------------+-----------+
| [Login    | [Search     | [Cart page]     | [Profile    | [Signup]  |
|  via OTP] |  filters]   | [Payment API]   |  photo]     | [Home UI] |
| [Dark     | [Wishlist]  | [Order email]   | [Coupon     |           |
|  mode]    |             |                 |  codes]     |           |
| [Reports] |             |                 |             |           |
+-----------+-------------+-----------------+-------------+-----------+
                             In Progress is full (3/3):
                             nobody may start a new card here
                             until one moves to Review.

Read the board like this:

  • Review is full (2/2), so finished development work cannot move forward. Developers should help review instead of starting new work. This is the famous Kanban idea: stop starting, start finishing.

  • A column that is always full while the next one is empty is a bottleneck.

  • Backlog and Done usually have no WIP limit.

Why limit WIP?

Limiting WIP feels strange at first: wouldn't the team get more done by starting more? No, for three reasons:

  1. Context switching is expensive. A developer juggling five tasks spends time reloading each one into their head.

  2. Unfinished work delivers no value. Ten half-built features are worth less to a user than three finished ones.

  3. Queues increase waiting time. As Little's Law below shows, with the same throughput, more WIP means every item takes longer.


Kanban Principles and Practices

The Kanban Method lists principles in two groups and six general practices.

Change management principles

  1. Start with what you do now. No new roles or ceremonies are forced on the team; you map your existing process onto a board.

  2. Agree to pursue improvement through evolutionary change. Small, continuous improvements instead of a big reorganization.

  3. Encourage acts of leadership at all levels.

Service delivery principles

  1. Understand and focus on customer needs and expectations.

  2. Manage the work; let people self-organize around it.

  3. Regularly review the network of services and its policies in order to improve outcomes.

The six general practices

PracticeWhat it means in a software team
VisualizePut every work item and every workflow stage on a board (physical or Jira/Trello-style).
Limit WIPSet a maximum number of items per column (or per person) and respect it.
Manage flowWatch how items move; unblock stuck cards; reduce waiting time.
Make policies explicitWrite down rules such as the definition of "ready" or "done" for each column, and how urgent items are handled.
Implement feedback loopsDaily stand-up at the board, regular replenishment and delivery reviews, retrospectives.
Improve collaboratively, evolve experimentallyUse data and models to try small changes and keep the ones that help.

The Kanban Guide condenses this into three practices: defining and visualizing the workflow, actively managing items in the workflow, and improving the workflow.


Flow Metrics and Little's Law

Kanban teams improve using data. The Kanban Guide names four measures every team should track:

MetricDefinition
WIPNumber of items started but not yet finished.
ThroughputNumber of items finished per unit of time (for example, per week).
Work Item AgeTime elapsed since an item started, for items still in progress.
Cycle TimeTime from when an item started to when it finished.

You will also hear lead time, usually meaning the time from when a customer requests something to when it is delivered. Lead time ≥ cycle time, because it includes the waiting time in the backlog.

Little's Law

These metrics are tied together by a result from queueing theory, proved by John Little in 1961. For a stable system, over a long period:

Average Cycle Time = Average WIP ÷ Average Throughput

It holds only on average and only when the system is reasonably stable (items that start eventually finish, and WIP is not growing without bound).

Worked example

A team has on average 12 items in progress and finishes 4 items per week.

Average cycle time = 12 ÷ 4 = 3 weeks

The team introduces WIP limits and brings average WIP down to 8. Their throughput stays at 4 items per week (they are the same people working the same hours).

Average cycle time = 8 ÷ 4 = 2 weeks

Each item now reaches the customer a week sooner, without anyone working harder. This is the mathematical reason behind "stop starting, start finishing".

Another example: a support team finishes 6 tickets per day and wants an average cycle time of 5 days. What average WIP is consistent with that? Rearranging, WIP = cycle time × throughput = 5 × 6 = 30 tickets.

Cumulative Flow Diagram (CFD)

A CFD plots, for each day, how many items are in each stage, stacked as coloured bands. By convention the "Done" band is drawn at the bottom and the earliest stage (for example, Backlog or Ready) at the top. Widening in-progress bands mean WIP is growing (work is piling up); a flat "Done" line means nothing is being finished. It is a common exam term: just remember that the vertical distance between the arrival line and the departure (Done) line shows WIP on a day, and the horizontal distance between them gives an approximate cycle time.


Kanban vs Scrum

AspectScrumKanban
CadenceFixed-length Sprints (one month or less)Continuous flow; cadences (reviews, replenishment) are optional and separate
RolesProduct Owner, Scrum Master, DevelopersNo mandatory roles; start with existing roles
Limiting workWork is limited per Sprint by the Sprint BacklogWork is limited per stage by WIP limits
Change during iterationSprint Goal should not be endangered; scope is negotiated with the Product OwnerNew items can be pulled any time capacity frees up
Key metricsProgress toward Sprint and Product Goals (many teams use velocity or burndown)WIP, throughput, cycle time, work item age
Best fitProduct development with planned incrementsSupport, maintenance, operations, unpredictable incoming work

Many teams combine them: Scrum events plus a Kanban board with WIP limits. This mix is often nicknamed Scrumban.


Part 2: Extreme Programming (XP)

Extreme Programming was created by Kent Beck in the mid-1990s, while leading the Chrysler Comprehensive Compensation (C3) payroll project, where Ron Jeffries coached the team; many of the ideas grew out of Beck's earlier work with Ward Cunningham. Beck's book Extreme Programming Explained was published in 1999, with a second edition in 2004. Beck was later one of the authors of the Agile Manifesto (2001).

The name comes from a simple idea: take good practices and turn them up to the extreme.

  • If code reviews are good, review code all the time: pair programming.

  • If testing is good, test all the time, even before writing code: test-first development.

  • If integration is good, integrate many times a day: continuous integration.

  • If design is good, improve the design every day: refactoring.

  • If short iterations are good, make them very short: small releases, iterations of one to two weeks.

Extreme Programming (XP) is an agile software development method that emphasizes customer satisfaction, very short iterations, and a set of tightly connected engineering practices such as pair programming, test-driven development, continuous integration and refactoring, so that the software can respond cheaply to changing requirements.

The XP values

The second edition lists five values:

ValueMeaning
CommunicationTalk face to face; share knowledge through pairing and an on-site customer.
SimplicityDo the simplest thing that could possibly work; don't build for imagined futures (often summarized as YAGNI, "You Aren't Gonna Need It").
FeedbackFrom tests (minutes), from the customer (days), from releases (weeks).
CourageRefactor, throw away bad code, tell the truth about estimates and progress.
RespectTeam members care about each other and the project (added in the second edition).

The 12 classic XP practices

Most textbooks and exam questions use the twelve practices from the first edition:

PracticeShort description
Planning gameCustomer writes user stories and sets priorities; developers estimate. Together they choose what goes into the next release and iteration.
Small releasesPut a simple working system into production quickly, then release new versions in short cycles.
MetaphorA simple shared story of how the system works, used to guide naming and design.
Simple designThe design should be as simple as possible at any moment; extra complexity is removed.
TestingProgrammers write unit tests (test-first); customers define acceptance tests.
RefactoringRestructure code without changing behaviour, to remove duplication and improve clarity.
Pair programmingAll production code is written by two people at one machine.
Collective ownershipAnyone can change any code anywhere in the system.
Continuous integrationIntegrate and build the system many times a day, running all tests each time.
40-hour weekSustainable pace: no overtime two weeks in a row (later called "energized work").
On-site customerA real user sits with the team, available to answer questions.
Coding standardsEveryone writes code the same way, which makes collective ownership practical.

The second edition reorganized these into "primary" and "corollary" practices with new names (for example sit together, whole team, weekly cycle, quarterly cycle, ten-minute build, test-first programming, incremental design). The ideas are the same; if an exam asks for XP practices, the twelve above are the safe answer.

Why the practices support each other

XP practices are designed as a web, not a menu. Take one away and others become risky:

  • Refactoring is safe only because automated tests catch mistakes.

  • Collective ownership works only with coding standards and pair programming spreading knowledge.

  • Simple design is acceptable only because refactoring lets you improve the design later.

  • Small releases need continuous integration so the system is always in a releasable state.


Pair Programming

Two developers share one workstation:

  • The driver types and thinks about the line of code being written.

  • The navigator reviews each line as it is typed, thinks about the bigger picture, spots bugs and suggests tests.

They swap roles often, and pairs rotate so knowledge spreads across the team. The common objection is "two people, one task, so half the output". Research and experience suggest the total effort is somewhat higher than solo work, but the code has fewer defects, the design is better, and knowledge is not locked in one person's head (reducing the "bus factor" risk). It is not double the cost.


Test-Driven Development (TDD)

XP's test-first practice grew into Test-Driven Development, which follows a short loop:

   +--------+        +---------+        +------------+
   |  RED   | -----> |  GREEN  | -----> |  REFACTOR  |
   | write a|        | write   |        | clean up   |
   | failing|        | minimum |        | code, keep |
   | test   |        | code to |        | tests green|
   +--------+        | pass    |        +-----+------+
        ^            +---------+              |
        +-------------------------------------+

Worked example in Python

Requirement: a function is_leap(year) following the Gregorian rule (divisible by 4, except centuries, unless divisible by 400). We write the tests first:

# test_leap.py
import unittest
from leap import is_leap

class TestLeap(unittest.TestCase):
    def test_divisible_by_4(self):
        self.assertTrue(is_leap(2024))

    def test_not_divisible_by_4(self):
        self.assertFalse(is_leap(2026))

    def test_century_not_leap(self):
        self.assertFalse(is_leap(1900))

    def test_400_is_leap(self):
        self.assertTrue(is_leap(2000))

if __name__ == "__main__":
    unittest.main()

Red. A first, too-simple implementation:

# leap.py
def is_leap(year):
    return year % 4 == 0

Running python -m unittest test_leap:

Output:

.F..
======================================================================
FAIL: test_century_not_leap (test_leap.TestLeap.test_century_not_leap)
----------------------------------------------------------------------
Traceback (most recent call last):
  File ".../test_leap.py", line 13, in test_century_not_leap
    self.assertFalse(is_leap(1900))
AssertionError: True is not false

----------------------------------------------------------------------
Ran 4 tests in 0.001s

FAILED (failures=1)

The test tells us exactly which rule we missed. Green. Write just enough code to pass:

# leap.py
def is_leap(year):
    if year % 400 == 0:
        return True
    if year % 100 == 0:
        return False
    return year % 4 == 0

Output:

....
----------------------------------------------------------------------
Ran 4 tests in 0.000s

OK

Refactor. Now we can rewrite it more compactly, with confidence, because the tests will shout if we break anything:

# leap.py
def is_leap(year):
    return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)

Output:

....
----------------------------------------------------------------------
Ran 4 tests in 0.000s

OK

Notice the tests also act as documentation: anyone reading them learns the leap-year rule.


When XP Fits, and When It Does Not

Good fitPoor fit
Small to medium co-located teams (roughly 2 to 12 developers)Very large or widely distributed teams
Requirements that change oftenFixed-scope, fixed-price contracts with heavy upfront documentation
A customer representative is available every dayCustomer is unavailable or only reachable through formal documents
Technology that allows fast automated testing and buildsBuilds take hours; testing needs special hardware

Scrum, Kanban and XP side by side

AspectScrumKanbanXP
Main focusTeam organization and planningFlow of workEngineering practices
IterationsSprints, one month or lessNone required1 to 2 weeks typically
Prescribes coding practices?NoNoYes (TDD, pairing, CI, refactoring)
Changes mid-iterationDiscouraged if it endangers the Sprint GoalAny time capacity allowsUnstarted stories of similar size can be swapped
Customer involvementThrough the Product OwnerThrough explicit service policies and reviewsOn-site customer

Common Mistakes

  • Calling any task board "Kanban". A board without WIP limits and flow management is just a to-do list.

  • Treating WIP limits as targets. A limit is a maximum, not a quota to fill.

  • Confusing lead time and cycle time. Lead time starts at the request; cycle time starts when work starts.

  • Using Little's Law on an unstable system. It describes long-run averages; it does not predict one item's duration.

  • Saying pair programming doubles cost. It costs somewhat more effort but reduces defects and spreads knowledge.

  • Thinking TDD means "write tests at the end". In TDD the failing test comes first.

  • Picking XP practices selectively. Refactoring without tests, or collective ownership without standards, quickly causes damage.


Interview and Exam Questions

Q1. What is a WIP limit and why does it help?

The maximum number of work items allowed in a workflow stage at one time. It reduces multitasking, exposes bottlenecks (a full column signals a problem), and, by Little's Law, reduces average cycle time at a given throughput.

Q2. A team's average throughput is 5 items per week and average WIP is 15. What is the average cycle time? If WIP is cut to 10 with the same throughput?

Cycle time = WIP ÷ throughput = 15 ÷ 5 = 3 weeks. With WIP 10: 10 ÷ 5 = 2 weeks.

Q3. Name the five XP values.

Communication, simplicity, feedback, courage and respect (respect was added in the second edition of Extreme Programming Explained).

Q4. What are the roles in pair programming?

Driver (types, focuses on the current line) and navigator (reviews, thinks strategically, looks for errors). They switch frequently.

Q5. Explain the TDD cycle.

Red: write a small test that fails. Green: write the minimum code to make it pass. Refactor: improve the code's structure while keeping all tests passing. Repeat.

Q6. How does Kanban differ from Scrum?

Scrum works in fixed-length Sprints with defined roles and events and limits work per Sprint. Kanban has no mandatory iterations or roles; it limits work per workflow stage using WIP limits and manages continuous flow using metrics like cycle time and throughput.

Q7. Which XP practice ensures any developer can modify any part of the code?

Collective (code) ownership, supported by coding standards, pair programming and a full automated test suite.


Summary

  • Kanban comes from Toyota's pull system; in software it means visualizing work, limiting WIP and managing flow.

  • Kanban Method practices: visualize, limit WIP, manage flow, make policies explicit, implement feedback loops, improve collaboratively and evolve experimentally.

  • Key flow metrics: WIP, throughput, work item age, cycle time. Little's Law: average cycle time = average WIP ÷ average throughput.

  • XP (Kent Beck) pushes good engineering practices to the extreme: pair programming, TDD, continuous integration, refactoring, small releases, simple design.

  • XP values: communication, simplicity, feedback, courage, respect.

  • Scrum organizes the team, Kanban manages the flow, XP improves the code. They combine well.

Kanban helps you finish work sooner; XP helps you keep that work easy to change.