API Design - Matt Gemmell
mattgemmell.com
API Design - Matt Gemmell
1–10 of 28 posts
Re: API Design - Matt Gemmell
#2This simple statement just changed the way that I think about API's.
Re: API Design - Matt Gemmell
#3"APIs are UX for developers." This simple statement just changed the way that I think about API's.
Re: API Design - Matt Gemmell
#4The only thing I'd argue with is: "Use semantic objects for parameters".
I haven't had any trouble passing a null pointer and casting it. Your API is going to be expanding regularly and the more message-passing objects you create, the more message passing objects' definitions you'll have to expand as the API expands.
Re: API Design - Matt Gemmell
#5"APIs are UX for developers." This simple statement just changed the way that I think about API's.
Re: API Design - Matt Gemmell
#6Re: API Design - Matt Gemmell
#7orthologonal - Properties and methods should not overlap in functionality. If two methods do sort of the same thing but differently that is a design issue. They should either do entirely different things or there should only be one method. Providing two is confusing and can potentially lead to bugs.
consistent - Naming of methods, properties and other entities should be consistent. Example if you have a method "getColor" you should not have a method "get_width" or "width" or any other variation. You should stick with one format. In the same way argument orders should be consistent. For example, if you have a method "translateCoords(x, y)" you should not have a method "setTopRight(y, x)". This principle is extensible into other domains as well (such as exceptions).
composable - Methods and functions should be reasonably composable. Instead of creating giant methods which do many things create small methods which do one thing really well. Then provide a clear way to compose methods together in order to accomplish a task. In this way methods do not have to be written which explicitly perform complex tasks.
learnable - All design is for naught if the API is not well documented. Much has been written on the importance of this step but it should be stressed again. Good documentation can make up for any number of short comings in the design. So document your api, provide examples of how to accomplish tasks.
discoverable - Hand in hand with documentation comes the ability to be able to naturally discover other parts of an API. This can be provided in a number of ways based on language and platform. In Python providing great dynamic help via the "help()" command and docstrings is a good start. For web APIs consider providing an "explain" API which returns documentation.
Re: API Design - Matt Gemmell
#8Re: API Design - Matt Gemmell
#9 Intuitive
Forgiving
Frictionless
Most of this article applies equally well to humans...Re: API Design - Matt Gemmell
#10This is a great document. Lots of detail, good recommendations. I recently gave a short lecture on API design and came up with the following "touchpoints" of API design. These are sort of general guidelines and a lot less specific than the article was. orthologonal - Properties and methods should not overlap in functionality. If two methods do sort of the same thing but differently that is a design issue. They should…
I'd also say that discoverability does not matter as much as documentation, IMO only very extensive APIs with lots of endpoints would actually benefit from it. I.e., in the case of web service APIs, don't waste resources on implementing complex nested endpoints with discoverability and HATEOAS when just a bit of clear documentation would do.