![]() Possibilities that elude your imagination may be clear to others.Īvoid fixed limits on input sizes. Show your design to as many people as you can, and take their feedback seriously. You can't reasonably hope to imagine everything that everyone will do with an API, or how it will interact with every other part of a system.ĪPI design is not a solitary activity. Most APIs are overconstrained.Įxpect API-design mistakes due to failures of imagination. You can't please everyone so aim to displease everyone equally. Any mistakes will come back to haunt you a thousand fold. If an API is used widely, its examples will be the archetypes for thousands of programs. Not only will this protect you from rude surprises, but the resulting code will become the examples for the API, the basis for tutorials and tests.Įxample code should be exemplary. ![]() Maintain the code for uses-cases as the API evolves. This will save you from implementing, or even specifying, a fundamentally broken API. This makes it easy to restructure the API when you don't get it right the first time.Ĭode the use-cases against your API before you implement it, even before you specify it properly. Structure requirements as use-cases: they are the yardstick against which you'll measure your API.Įarly drafts of APIs should be short, typically one page with class and method signatures and one-line descriptions. People often provide solutions it's your job to ferret out the underlying problems and find the best solutions. When designing an API, first gather requirements-with a healthy degree of skepticism. In fact, it should rarely require documentation to write it. APIs should be self-documenting: It should rarely require documentation to read code written to a good API.
0 Comments
Leave a Reply. |