Book Deep Read · Fundamentals of Software Architecture · Chapter 6

Measuring and Governing Architecture Characteristics: Turning -ilities into Tests That Go Red

Fundamentals of Software Architecture · Ch 6 · Mark Richards & Neal Ford · 2020

中文 →

What is this chapter about?

The last two chapters taught you to pick the few qualities a system must have: fast, stable, easy to change. This chapter asks the uncomfortable follow-up: once you've picked them, who makes sure they stay true? The system behind your banking app is quick today. Six months and a few thousand changes by dozens of people later, is it still quick? Nobody knows — unless someone keeps measuring.

An analogy: the smoke alarm

A building code says the stairwell must stay clear as a fire exit. On inspection day it's empty. Then people move in: someone leaves a box, someone parks a bike, and a year later the exit is blocked. A sign on the wall doesn't help, and a yearly inspection comes too late. What works is a smoke alarm: nobody has to watch, it goes off by itself when something's wrong. This chapter is about installing smoke alarms in software.

Why the old way was hard

These qualities are fuzzy. What does "easy to change" actually mean? Is "fast" fast on average, or fast even for the slowest visitor? Ten people give ten definitions, and some words are really a bundle — "flexible" quietly includes easy to test, easy to release, and cleanly split into parts. If you can't define it, you can't measure it; if you can't measure it, you can't protect it.

The core idea: make it a number, then hand it to a machine

Step one is breaking fuzzy words into things you can count, and the book sorts them three ways. Some look at how the running system behaves, like how long a page takes to open. Some look at the shape of the code itself, like how many "if this, then that" forks a piece of a program has — more forks means harder to read and harder to test fully. And some look at how the team works, like how many of every ten releases cause trouble.

Step two is writing these checks as small tests that run automatically. The book calls them "fitness functions" — think of a health checkup item for each quality. Every time a programmer submits a change, the machine runs them all: if someone takes a shortcut and reaches straight into the database against the rules, the test turns red on the spot and the change is blocked.

What it gives you / how to choose

The rules move from "someone has to remember" to "the machine remembers for you", and the architect stops policing people. Which ones to install? Only for the top three qualities. The honest cost: only what you can measure gets protected, and alarms need upkeep too — install too many that go off for nothing, and people switch them off.

One line to remember

Architecture rules on paper slowly rot; turn them into numbers and let a machine check them every day, and only then do they really stand.

Want the concrete metrics in each category, how cyclomatic complexity is counted, ArchUnit layer tests and Netflix's Simian Army? → Switch to Deep