cri.dev
about posts rss

4 rules of simple design

Published on
Tagged with rules1 design2 tests5

https://martinfowler.com/bliki/BeckDesignRules.html by Martin Fowler

Developed in the late 1990’s, the rules of simple design are:

  • Passes the tests
  • Reveals intent
  • No duplication
  • Fewest elements

These rules are ordered, thus “passes the tests” takes precedence over “reveals intent”

Passes the tests is the most important one. (Since introduced when XP started to get traction and be a first-class activity when writing software). The primary aim of tests is to verify that the system works as intended.

Reveals intent means that the code should be easy to understand. In XP, Communication is a core value, and code is written and read by programmers.
The best way to make your code understandable, is to express your intention in code.

No duplication means that by eliminating duplicate code is a good way to create good designs. It follow the DRY and SPOT principle.

Fewest elements means in a few words to have clear, concrete elements/classes without unnecessary indirection. This rule was established when oftentimes to enable flexibility, lots of classes were added to the architecture, although this mostly made the code harder to modify and less flexible in practice.

Here, have a slice of pizza 🍕