Book Deep Read · Fundamentals of Software Architecture · Chapter 12

Microkernel Architecture: A Small Core Guards the Main Flow, Change Lives in Plug-ins

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

中文 →

What is this chapter about?

You have probably installed browser extensions: an ad blocker, a translator, a password manager. The browser itself never changes; each extension adds one new trick, and removing it doesn't stop you from browsing. Code editors work the same way: install a plug-in and it suddenly speaks a new language. This chapter is about that shape of software: a small, stable core plus a ring of plug-ins you can add and remove. The book calls it the microkernel architecture, also known as the plug-in architecture.

An analogy: a stand mixer with a socket

A kitchen stand mixer does one thing: it spins. Want to knead dough? Attach the dough hook. Whisk eggs? The whisk. Grind meat? The grinder attachment. The attachments don't know each other; each just has to fit the one standard socket on the machine. When the maker releases a new attachment, you keep your old mixer.

Why the old way hurts

Without this, every special case lives in the main program: "if it's this phone model, price it this way; if it's that one, price it that way." A year later there are hundreds of ifs. Touching one might break another, and adding a new phone model means retesting and redeploying the whole program.

The mechanism: machine, attachments, catalog, socket

There are only four things. The machine does only the main routine that every job goes through. Attachments: one per special case, each minding its own business, never talking to the others. A catalog: the machine keeps a list of which attachments exist and where to find them. A standard socket: every attachment plugs in the same way, so the machine never needs to know how one works inside.

Some attachments can only be swapped with the power off; others can be swapped while it runs. The second kind is handier but needs a fancier machine.

What it buys you / when to choose it

It fits software where the core is fixed but the variations keep changing: browsers, editors, tax software, insurance claims whose rules differ by region. It is cheap, easy to understand, and new variations don't touch old code. The cost: it is usually still one single machine, so you can't add capacity to just the busiest attachment, and if the core goes down everything stops.

One line to remember

Microkernel is a small core + plug-ins + a catalog + a standard socket: lock what changes inside plug-ins, and the core can stay still for years.

Want the two definitions of the core, the three ways to connect plug-ins, registries and contracts, the book's device-recycling and insurance examples, and the star ratings? → Switch to Deep