Book Deep Read · Fundamentals of Software Architecture · Chapter 6
Fundamentals of Software Architecture · Ch 6 · Mark Richards & Neal Ford · 2020
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.
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.
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.
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.
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.
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
You think that once architecture characteristics are chosen and written down, the job is done — in fact an unmeasured characteristic quietly erodes commit by commit. FoSA Chapter 6 first breaks fuzzy -ilities into three kinds of measurable metrics — operational, structural, process — then uses fitness functions to turn them into checks that run on every build, so architecture governance shifts from "review the diagram in a meeting" to "the test went red".
Part I, "Foundations", Chapter 6 — the third of four chapters on characteristics: Chapter 4 defines them, Chapter 5 identifies them, this one covers how to measure and guard them, Chapter 7 covers their scope. The fitness-function idea comes from Ford et al.'s earlier Building Evolutionary Architectures (2017). Real-world counterparts: architecture checks in a CI pipeline, deployment success rates on a release dashboard, latency alerts in monitoring.
The architect and the business picked "deployability, performance, testability". Now what? The book names three problems with such words. They aren't physics — "agility" has no unit you can read off like temperature. Definitions vary wildly — for the same "performance", the front-end team means time to first render and the back-end team means throughput. They're too composite — "agility" is really modularity, deployability and testability combined, and can't be tested as a whole.
What if you don't solve it? The characteristics stay wishes. Picture a 40-person team merging 60 changes a day. One day, under deadline, someone lets UI code query the database directly — it works, and code review misses it. Three months later there are dozens of such shortcuts, the layering exists in name only, and "maintainability" survives as one bullet on a slide. Human review can't catch this slow erosion, because each violation looks small on its own. The chapter's answer: define objectively first, then guard automatically.
The book sorts usable measures into three kinds, matching three places characteristics live (see Table 1 below):
Operational measures are the most intuitive, with performance the classic case: the simplest are average and maximum response time. But the book notes that mature teams don't just pin a hard number; they build a normal range from statistical analysis and alert when behavior leaves the model — an average lets a mass of fast requests hide a few very slow ones, the same reason DDIA Chapter 1 reads latency in percentiles. The front end adds a K-weight budget — a cap on how many KB of scripts and frameworks a page may download — plus metrics like time to first render.
Process measures quantify how delivery works: testability via code coverage; deployability via the ratio of successful to failed deployments, how long each deployment takes, and how many bugs deployments introduce. A composite like "agility" gets split into parts that can each be counted.
On the structural side the book focuses on cyclomatic complexity (CC), introduced by Thomas McCabe in 1976. The intuition: draw a function as a control-flow graph, statements as nodes and possible jumps as edges; CC is roughly the number of independent execution paths through the code. For a single function the formula is CC = E − N + 2 — edges minus nodes plus 2; in plain words, every extra if, loop or branch condition adds 1.
Why care? Higher CC means code that's harder to understand, needs more test cases, and hides bugs more easily. The book cites the industry threshold that a function CC under 10 is generally acceptable, but the authors find that too lenient and prefer under 5. The exception is an inherently complex domain (tax rules, say), where the complexity comes from the problem itself and forcing it down just scatters the logic. The book also observes that teams practicing test-driven development (TDD) tend to produce lower-CC code — writing the test first naturally keeps functions small. Chapter 3's distance from the main sequence and cycle checks belong here too: a checkup on the code's own structure.
"Governance" comes from the Greek kubernan, "to steer". What the architect steers are the characteristics that, left unsupervised, get pushed off course by the many forces in the development process. The chapter's central tool is the fitness function, defined in Building Evolutionary Architectures as any mechanism that provides an objective integrity assessment of some architecture characteristic or combination of characteristics.
The name is borrowed from evolutionary computing: a genetic algorithm scores each generation with a fitness function, judging how close a candidate solution is to the goal, and culls the weak. Applied to architecture, each commit is a "mutation", and the fitness function judges whether it pushed the system away from the characteristics it promised. The key line: fitness functions are not a new framework but a new perspective on existing tools — monitors, metrics, unit-test libraries, chaos engineering all qualify once they're used to objectively guard an architecture characteristic.
Cyclic dependencies: modules referencing each other tangle the system into a knot. The book uses the Java tool JDepend in a test that scans every package and fails if it finds any cycle. A developer adds a convenient import in the IDE without noticing it closes a loop; the test points it out at build time. The same tool can assert that each package's distance from the main sequence stays under a threshold.
Layer constraints: ArchUnit (Java) or NetArchTest (.NET) let you write the architecture diagram as a test, roughly "define Controller, Service and Persistence layers; Controller may not be accessed by any layer, Persistence may only be accessed by Service". The "UI queries the database directly" shortcut from earlier goes red on its very first commit. The architecture diagram becomes executable.
Fitness functions in production: Netflix's Simian Army. Chaos Monkey randomly kills production instances, forcing the system to prove its fault tolerance; Conformity Monkey checks that services follow best practices; Security Monkey checks security configuration; Janitor Monkey cleans up unused resources. The book treats them as holistic fitness functions running continuously in production.
The book stresses that fitness functions aren't punishments dropped from an ivory tower. The authors liken them to the checklists surgeons and pilots use (borrowing from Atul Gawande's The Checklist Manifesto): checklists exist not because experts don't know, but because under pressure the easiest things to skip are exactly the ones "everybody knows". So the architect must make developers understand the purpose of each check before wiring it into the pipeline — otherwise, the first time a test goes red, the reflex is to comment it out.
Table 1 · The three kinds of measures
| Kind | Guards | Typical metrics | Cost / trap |
|---|---|---|---|
| Operational | performance, scalability, elasticity | avg / max response time, first render, K-weight budget | averages hide the tail; hard thresholds false-alarm, need a statistical baseline |
| Structural | maintainability, modularity | cyclomatic complexity, cycles, distance from main sequence | thresholds are subjective; complex domains "legitimately" exceed them |
| Process | testability, deployability, agility | coverage, deploy success rate, deploy time and bugs | easiest to game: high coverage ≠ useful assertions |
Table 2 · Where to run a fitness function (our summary)
| Where | Good for | Upside | Cost |
|---|---|---|---|
| Build / pre-merge | layers, cycles, CC, coverage | fastest feedback; problems never reach main | slows the pipeline; a false positive blocks everyone |
| Scheduled job | dependency versions, structural trends | doesn't block work; shows long-term drift | found late, when fixes cost more |
| Production | latency, availability, fault tolerance, compliance | measures real behavior | user-visible risk; needs mature monitoring and rollback |
The selection rule goes back to Chapter 5: write fitness functions only for the top three characteristics. Each one is code to maintain, and a dozen half-true checks are worse than three that truly hold — the team learns to ignore red. The other choice is block or warn: structural rules (layers, cycles) have crisp boundaries and suit hard blocking; operational metrics fluctuate, so start with alerts, build a baseline, then tighten.
In an architecture review: don't hand over just a diagram, hand over a set of tests that can go red — "these three layer rules, this p99 alert, this deploy-failure dashboard are the three characteristics we committed to". In an interview: asked "how do you keep microservices from turning into a distributed big ball of mud?", answering "encode dependency rules in CI with ArchUnit-style tools, plus production latency and availability alerts" is exactly this chapter's skill.
① An unmeasured characteristic is just a wish, and it erodes slowly through everyday commits.
② Three reasons characteristics are hard to measure: not physics, wildly varying definitions, too composite.
③ Three kinds of measures: operational (response time, first render), structural (cyclomatic complexity, cycles), process (coverage, deploy success rate).
④ Cyclomatic complexity ≈ number of independent paths; industry says under 10 is fine, the authors prefer under 5.
⑤ Fitness function: any mechanism that objectively assesses an architecture characteristic, borrowed from evolutionary computing.
⑥ It's not a new framework but a new way of seeing monitors, tests and chaos engineering.
⑦ Typical uses: JDepend for cycles, ArchUnit for layers, Netflix's Simian Army for production.
⑧ Explain the purpose before wiring it in, or the red light gets commented out; write them only for the top three.
⑨ Interview line: "Make the architecture diagram executable — encode the rules as tests in CI that go red."