Application, Structure And Protocol
... de-coupling common patterns in API design: the "what", "where" and "how".
Some things takes a while to digest, and this is a message from Mike that is taking me some time. Like a good wine, it takes experience and trying things to appreciate: and this one is still not going down super smoothly to me (and honestly, as a community, I still believe we have to agree on terminology here).
What I'm learning the hard way is that you want to de-couple your API design in three independent layers of specificity:
- the "what": application e.g. events, people, photos, videos, etc
- the "where": structure e.g. text/html, text/json, text/xml, json-ld, etc
- the "how": protocol e.g. http://, tel://, mailto://, android-app://, etc
As you move down, the more generic/opaque the message is: the less you know about the message. And you want all of these components to be used/replaced/switched independently.
Here is the metaphor that I use to explain to my co-workers.
When You Start Writing A Letter You First Figure Out "What" To Write ...
... A love letter, a thank you note, a note, etc. You use "domain-specific" language between you and your recipient, like slang, nicknames and emotions. You use recipient-specific common notions on how to organize the world (taxonomies) as well as belief systems (ontologies).
... You Also Decide What's The Most Convenient Paper Format To Convey Your Message ...
You pick the paper color, shape, size and layout. If the content of the message is short, you pick a small paper. If the content of the message has structure, you pick a more structured layout. If you are writing free-form, you pick a blank paper.
... and you also have to decide how the letter is going to be delivered ...
You pick different trade offs between cost and delivery guarantees: re-try policies, tracking numbers, latency, etc.
But More Importantly, You Want To Allow Yourself To Use Any Combination Of These.
You want to have the ability to write about a variety of things, under a variety of paper layouts across a variety of delivery methods.
And This Translates To Designing Your Hypermedia API
You want to allow your domain-specific vocabularies (e.g. schema.org, ogp.me, microformats.org or your custom own) to be conveyed in a variety of formats (e.g. web pages, email messages, android XML UIs, etc) and to be transported using different mechanisms (e.g. http, smtp, android intents, etc).
So, Where Do We Go From Here?
Above and beyond of course!
While I think there is a lot of work to be done in all of these different levels, having already gone through a lot of time understanding the top layer, I'm particularly interested in the middle layer (structure/layout) - starting from where it currently falls short.
Stay tuned!