Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AlexGalhardo/41ee36ebecd9d1ac0d85a1270b1164fd to your computer and use it in GitHub Desktop.
Save AlexGalhardo/41ee36ebecd9d1ac0d85a1270b1164fd to your computer and use it in GitHub Desktop.
The Four Elements of Simple Design

The Four Elements of Simple Design

The rules can be stated as followed:

  1. Passes all tests
  2. Maximizes clarity
  3. Minimizes duplication
  4. Has fewer elements
  • The rules are listed in priority order.
    • e.g., Passes all tests trumps Maximizes clarity.
  • Rules 2 and 3 often seem to swap priority.
    • Minimizes duplication precedes Maximizes 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 trump Maximizes 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 above Minimizes 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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment