Book Deep-Read · A Philosophy of Software Design · Chapter 8

Pull Complexity Downward

A Philosophy of Software Design · Ch 8 · Pull Complexity Downward · Ousterhout · 2nd ed 2021

中文 →

What is this chapter about?

Anyone who builds software keeps running into a hassle that can't be avoided: if the network drops, should we try again, and how long should we wait first? Someone has to deal with it. The question is who — the person who builds the part, or everyone who uses it? The chapter's answer is blunt: better that the builder works a little harder than that every user has to.

An analogy

Picture two restaurants. One menu says: "Choose your own cooking: minutes on high heat, minutes on low, grams of salt." The other just says "braised pork" and leaves the heat and salt to the chef. The first one looks more "flexible," but it has quietly handed the chef's job to every diner. One chef thinking it through once beats a hundred diners each guessing.

Why the old way is hard

Builders have a natural shortcut: whenever they're unsure, they "let someone else decide." Not sure what to do when something goes wrong? Report an error and let the caller sort it out. Not sure which approach is best? Add a setting and let users fill it in. The part gets easier to build today. But a question that one person should have thought through now has to be thought through by every user — and they usually know less about the insides than the builder does.

How it works, intuitively

What it buys you / how to choose

When you hit a hassle, ask one question: can the user make a better decision here than I can? If not, take it on yourself. One honest cost: the inside of the part gets harder to write and harder to test, and the builder really does carry more of the load.

Remember it in one line

Give an unavoidable hassle to the one person who understands it best, to handle once — don't spread it across every user to handle again and again.

Want the argument that a simple interface matters more than a simple implementation, the text editor example, how a retry interval turns from a setting into something computed, the three tests for pulling down, and how TCP and Go's garbage collector bear the chapter out? → switch to Deep