Designing a REST API
Apigee has kindly written a book with simple illuminating examples on how to design a REST API.
It is short, concise and has good examples from the Real World like Google, Netflix and Twitter.
Apigee has kindly written a book with simple illuminating examples on how to design a REST API.
It is short, concise and has good examples from the Real World like Google, Netflix and Twitter.
When writing an API, be it a global Jquery or private CustomerFacade one has to do a bit of architecting/designing when coming up with method names and parameters. Sometimes they are natural but other times takes a bit of thinking and at other times again refuse to become anything good.
So don’t write the API. Yet. Write the calling code. The API is there to be used by someone (something) and should be readable, preferably easily.
When writing the call first one (i.e. I) often misses a parameter for complex methods. But then I just iterate.
Write the caller. Write the callee. Discover the callee lacks a parameter. Update the callee. Update the caller. Repeat once again. Notice the callee is complex and split it. Update caller. See that the caller shouldn’t be split. Add a method to the API and make the two earlier private. Update callee. Finished with a good working method. Continue to next task/method.