Reading diagrams / Topic 7 of 42

Shapes: stacks and hubs

The rule

Now put the pieces together. A shape is a pattern of boxes, levels and arrows that you can spot at a glance.

A stack has one package on every level above the bottom. Each part is built on the one below it, like a database engine that turns SQL text into steps, and steps into reads from disk pages.

A hub is a package that every other package imports. It is usually the shared vocabulary: the types the rest of the program passes around. A change to a hub reaches everything.

The rules are exact. A stack may have arrows that skip levels, as Interface's do in SQLite; it is still a stack while every level above the bottom holds one package. A package imported by seven of eight others is not a hub.

What a shape usually means is a rule of thumb from experience. The diagram confirms the shape, not what the program is for. In a review, a change that puts a second package on a level of a stack, or a package that stops importing the hub, has changed the shape, and that is worth a question to the author.

A copy of SQLite’s documented architecture.

Loading the layer diagram.

A copy of the TypeScript compiler’s documented architecture.

Loading the layer diagram.

Loading the worked examples and practice.