Four Rules for Software Design - Martin Fowler

These rules sound very like the MaidSafe approach I’ve heard @dirvine expound, and though I’ve long stopped writing code they sound right on to me:

Kent Beck came up with his four rules of simple design while he was developing ExtremeProgramming in the late 1990’s. I express them like this:

Passes the tests
Reveals intention
No duplication
Fewest elements

The rules are in priority order, so “passes the tests” takes priority over “reveals intention”


1 Like

Absolutely, test test and more tests, we have a mechanism where we use random data with random lengths etc. so you will see many tests run on multiple threads checking random info. This has proven invaluable in some complex testing situations (like can we encrypt / decrypt all data types etc.).

reveal intent => plus only a single intent, single responsibility rules

This goes with my other big point, the rule of “least astonishment” i.e. do not implement an equals without also implementing it’s partner not equals etc.

I would also rate single ownership as more important than deduplication, in many cases. So when calculating, do not let anyone near the thing, when it’s calculated make it immutable and share as much as you want, BUT only if you can ensure lifetimes are managed and agreed by all. Otherwise do not share at all :slight_smile:

The rest then follows nicely. Really good summation I think, nice find Mark.

1 Like