How to write a good API?

Good apis are easy to remember and unambiguous, promote code readability, accuracy, and efficiency, and help developers succeed.

I call these design directions “tier 1” because they are the first thing library developers need to focus on. You may have to cut out some of them and make trade-offs, but at least you can walk through them.

However, as long as you haven’t sent the nomad to Mars, your code will always change, and so will the API user’s code.

Some of the best API developers I know don’t stop at “tier 1” directions like readability, but instead devote as much effort as possible to what I call “tier 2” API design: how the code that uses this API evolves over time.

Small changes in requirements can tear even the most elegant code apart.

A good API will provide for this. They expected to you will want to move some parts code, copy and paste, rename, and special cases to extract into reusable helps procedures, the abstract back to specific situations, hack, optimization of bottlenecks, to give up part of then start again, have made a mistake, the cause and effect between, fix bugs, examination and repair code.

Good APIs will not only get you there, they will help you stay there.

They adapt.

Optimized for Change