All notes
1 min read
Deep modules beat clever interfaces
A small interface with the hard part hidden behind it. Callers should get to skip the mess.
A Philosophy of Software Design has a name for this: a deep module. Small interface, a lot of work behind it. Callers get one idea. The mess stays inside.
The opposite shows up all the time. A component with six props "for flexibility." A client that copies every backend endpoint instead of the few operations the product actually needs.
Depth isn't fewer lines. It's how much the caller gets to skip.
The book also says to define errors out of existence. Make the bad state hard to represent, and let one place own the policy.
When a change adds an abstraction, what did we hide, and for whom? If the answer is "not much," we just added surface.