Skip to content

Instantly share code, notes, and snippets.

@O-I
Last active October 24, 2024 21:12
Show Gist options
  • Save O-I/cf6eecc3c27200fdce652fc6f88d1a60 to your computer and use it in GitHub Desktop.
Save O-I/cf6eecc3c27200fdce652fc6f88d1a60 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:

@golubitsky
Copy link

golubitsky commented May 11, 2022

His exact wording appears in the White Book.

It's on page 109 (of the edition published in 2000)!

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