- Introduced by Kent Beck in the 1990s.
- Part of his software development methodology Extreme Programming.
- His exact wording appears in the White Book.
The rules can be stated as followed:
Passes all tests
Maximizes clarity
Minimizes duplication
Has fewer elements
- The rules are listed in priority order.
- e.g.,
Passes all tests
trumpsMaximizes clarity
.
- e.g.,
- Rules 2 and 3 often seem to swap priority.
Minimizes duplication
precedesMaximizes clarity
in most versions (including Beck's).- Really, rules 2 and 3 feed off of each other like a dynamo.
- When writing code,
Minimizes duplication
seems to trumpMaximizes clarity
, but when reading code, the reverse seems to be true. - On average, a developer will spend 10 times longer reading and understanding code
than writing it. As a result, I personally place
Maximizes clarity
aboveMinimizes duplication
, but it depends on what is being done and by whom.
- Rule 0: Kent Beck says:
In the rare case they are in conflict (in tests are the only examples I can recall), empathy wins over some strictly technical metric."
Further reading:
It's on page 109 (of the edition published in 2000)!