TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Best books in API design

36 pointsby grepover 14 years ago
What books do you recommend on the subject?

11 comments

silentbicycleover 14 years ago
While it's ostensibly about C, David Hanson's _C Interfaces and Implementations_ (<a href="http://sites.google.com/site/cinterfacesimplementations/" rel="nofollow">http://sites.google.com/site/cinterfacesimplementations/</a>) has a lot of good discussion about API design for libraries, how to handle errors gracefully, etc. Many points apply just as well to libraries in OO or functional languages, REST APIs, etc., because questions about who should be responsible for error checking, managing resources, etc., are going to come up in any API design.<p>It's also a good example of literate programming, and one of the best C books I've read.<p>I'd also recommend <i>against</i> _Design Patterns_, because while some of the API design discussion is good, much of it is too entangled with workarounds for quirks in C++'s object system. Visitor is irrelevant if you have multimethods, Singleton is a non-issue if you have a prototype-based object system, etc., but this isn't clear. C's lack of a specific object system makes the focus on API design clearer in CII.
评论 #1671298 未加载
jefffosterover 14 years ago
There's a good video available "How To Design A Good API and Why it Matters" by Josh Bloch. There's a selection of slides to accompany a version of the talk here <a href="http://lcsd05.cs.tamu.edu/slides/keynote.pdf" rel="nofollow">http://lcsd05.cs.tamu.edu/slides/keynote.pdf</a> [PDF].
评论 #1668949 未加载
评论 #1668835 未加载
bdover 14 years ago
Not a book, but Trolltech (makers of Qt) has nice recommendations for API design:<p><a href="http://doc.trolltech.com/qq/qq13-apis.html" rel="nofollow">http://doc.trolltech.com/qq/qq13-apis.html</a>
评论 #1669615 未加载
评论 #1668899 未加载
devmonkover 14 years ago
Good API design is such a broad topic (because there are a wealth of programming languages and ways you can communicate with systems and code) that you're not going to find one that probably suits you without being more specific.<p>Lets assume you are talking about a class API (like a C, C++, Java API for example) and are just either defining a library or an interface into your application from code that is loaded from the application's runtime environment. In that case I could say what you might look into first would be good OO design and head you off into "Design Patterns" as a classic (there is also an online Java equivalent of that book which I think is "Java Design Patterns"). But then you'll spend your years as a junior and mid-tier developer obsessed with designs and which design to best use. Having the right classes that "make sense" to a developer is wise, but spending too much time with patterns isn't.<p>What I'd suggest is to just look at a number of APIs similar to what you want and try to create something similar. Basically you want something intuitive, so design something similar to what developers are used to. Consider what needs to be public in the API. If it isn't providing something obviously and directly related, it should be in a different library. As for deprecation of methods over time, this used to be something that was done differently than now. Used to be that you would be concerned about people continuing to use your API with older code. These days a number of groups developing (especially for applications) will force people to change and update by making their API less backwards compatible (not many do this, but enough to make it hurt- and it sucks). Good luck!
garnaatover 14 years ago
If you are interested in REST API's, the best I've ever read is "RESTful Web Services" by Richardson &#38; Ruby.
ewanmcteagleover 14 years ago
Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries (2nd Edition) <a href="http://www.amazon.com/Framework-Design-Guidelines-Conventions-Libraries/dp/0321545613/" rel="nofollow">http://www.amazon.com/Framework-Design-Guidelines-Convention...</a> is an interesting read and contains the result of actual work on building a large and successful framework. Has information on exceptions, naming, extensibility, and common patterns.
locopatiover 14 years ago
Haven't read the book (it's on my long list), but the author has a decent blog riffing on API design ideas<p><a href="http://wiki.apidesign.org/wiki/Main_Page" rel="nofollow">http://wiki.apidesign.org/wiki/Main_Page</a> <a href="http://www.amazon.com/gp/product/1430209739" rel="nofollow">http://www.amazon.com/gp/product/1430209739</a>
grepover 14 years ago
What about: Service-Oriented Design with Ruby on Rails?<p>Any comments?<p><a href="http://www.amazon.com/Service-Oriented-Design-Ruby-Rails-Paul/dp/0321659368/ref=sr_1_fkmr0_2?ie=UTF8&#38;qid=1283868123&#38;sr=8-2-fkmr0" rel="nofollow">http://www.amazon.com/Service-Oriented-Design-Ruby-Rails-Pau...</a>
indyover 14 years ago
Interface Oriented Design by Ken Pugh is pretty good (<a href="http://pragprog.com/titles/kpiod/interface-oriented-design" rel="nofollow">http://pragprog.com/titles/kpiod/interface-oriented-design</a>)
nlover 14 years ago
Anything by Josh Bloch
c00p3rover 14 years ago
SICP