Book Deep-Read · Software Engineering at Google · Chapter 21

Dependency Management

Software Engineering at Google · Ch 21 · Dependency Management · Titus Winters · 2020

中文 →

What is this chapter about?

No app on your phone was written from scratch. It uses parts other people built, and those parts use more parts, layer upon layer. Those borrowed parts are called "dependencies." This chapter asks: the owners of those parts can change them at any time, and you have no say — how do you keep the whole machine from falling apart over the years?

A strange thing first

You'd think a part's version number tells you whether an upgrade is safe: a big version jump means be careful, a small one means go ahead. Google's experience is that a version number is just the author's guess. They think "I only fixed a tiny bug," yet some user was quietly relying on that bug. They think "this is a big change," yet you never used the part that changed — and you're still blocked from upgrading.

Why the old world is hard

Picture a renovation: you hire a carpenter and an electrician, and both use screws from the same factory. The factory releases a new screw with a different thread. The carpenter switches; the electrician sticks with the old one — and your house can only take one kind. Neither tradesperson did anything wrong, yet your house won't go together. Worse, you're the one who finds out, and you're neither a carpenter nor an electrician. The bigger the web of parts, the more often "both sides are right, together it fails" happens.

How it works, intuitively

What it buys you / how to choose

For a small project with a few well-maintained parts, version numbers are good enough. When the web reaches thousands of parts and the project must live for decades, put the burden on the part's author: if you want to change it, first prove you didn't break anyone. The honest cost: this needs automated checks everywhere and huge amounts of computing to run them — today, only a company at Google's scale manages it, and only inside its own walls.

One line to remember

A dependency isn't a one-time loan but a long-term contract; a version number is only the other side's guess, and the reliable answer comes from running the checks of everyone who uses it.

Want to see why diamond dependencies are nearly hopeless in C++, how SemVer both overconstrains and overpromises, the logic of Minimum Version Selection, how to choose among four dependency models, and the gflags and AppEngine cautionary tales? → Switch to the deep read