Tuesday, April 09, 2013

I saw this post today on Quora


By Katy LevinsonInstigator

she posted ( and i thought it was a most awesome post ! )

This is an API

This API takes circles, triangles, and squares and lets them into the box. It forces the user or client program to organize the inputs going into the box to the designer's liking, presumably so they're easier to work with.

If magic elves lived in the box, we could also have this API serve data out by having the elves push the shapes back out of the holes. This would be useful to the user/client program because now the outputs would come out in the way users expect them to. We would expect squares to come out of the square hole and not circles, and this example API would always do that.

APIs have many advantages. For security/sanity reasons, you generally do not want to not have a lid on your box. People could begin pushing star blocks or perhaps live sharks into the box, and this might be disagreeable to your magic elves. Conversely, perhaps one day you want to rearrange the insides of your box. This would be disagreeable to your users who would have to re-learn how to interface with your box. With this special lid on here, your users can not put anything in the box your elves do not like, and how you arrange the org chart of your magic elves inside remains inconsequential to your users.

In this way, an API forces structured data-based (or, in this example, block-based) exchanges between what the designer made and the outside world which wants to use it.