This is a card in Dave's Virtual Box of Cards.
APIs
Created: 2022-09-10
I’m 100% with John Ousterhout on the value of good APIs (interfaces).
In my own words, an API should:
-
Provide good defaults and make base cases easy
-
Not hide what cannot be hidden
-
Hide everything else and do the nasty work behind the scenes
A good API is a layer.
A good layer lets you think about just one thing at a time.
I think the "network "stack" is a great example: HTTP doesn’t know anything about TCP/IP, which doesn’t know anything about Ethernet, etc.
Layers are rarely perfect, but without them, we would drown in complexity.
Related: MVC Sucks.