Definition

A set of criteria, in priority order, proposed by Kent Beck to judge whether some source code is "simple enough":

  • the code is verified by automated tests, and all such tests pass
  • the code contains no duplication
  • the code expresses separately each distinct idea or responsibility
  • the code is composed of the minimum number of components (classes, methods, lines) compatible with the first three criteria

Common Pitfalls

The first criterion is easy to judge, but implies something far from trivial: namely that the source code in question is "correct", or has no defects. Unit tests are at best suggestive evidence that a program has no defects and certainly no definite proof. Pragmatically, however, Agile discourse considers them an excellent first line of defence.

The next two criteria leave more room for subjective judgment. For instance, code duplication can be taken literally, as character-for-character duplication. Since unfortunately "copy-paste programming" remains common industry practice, this is a frequent occurrence, which can be alleviated through diligent refactoring. However, competent programmers also recognize more subtle forms of duplication.

Similarly, many distinct attempts at formalizing the third criterion exist, none of them regarded as definitive. Examples include "low coupling and high cohesion" and the SOLID design principles.

Origins

Help Us Keep Definitions Updated

Let us know if we need to revise this Glossary Term.