In this article, Joshua Bloch, Chief Java Architect at Google and former Distinguished Engineer at Sun Microsystems, presents a list of maxims intended to be a concise summary of good API design guidelines. The maxims represent the abstract written by Joshua for his session "How to Design a Good API and Why it Matters" held during JavaPolis 2006.
Read Article: Joshua Bloch: Bumper-Sticker API Design
Watch Presentation: How to Design a Good API & Why it Matters
Community comments
Documentation...
by Seb Rose,
Re: Documentation...
by Kurt Christensen,
Re: Documentation...
by Albert Hwang,
Converting use-case tests into examples in tutorials: code citing
by Peter Arrenbrecht,
I've read this before.
by Jasper Novotny,
Re: I've read this before.
by Abel Avram,
Re: I've read this before.
by Rich Unger,
Re: I've read this before.
by Ilja Preuß,
Diamonds vs. stars
by Jaroslav Tulach,
A collection of resources on API design
by Christopher Bare,
Documentation...
by Seb Rose,
Your message is awaiting moderation. Thank you for participating in the discussion.
"APIs should be self-documenting: It should rarely require documentation to read code written to a good API. In fact, it should rarely require documentation to write it."
"Documentation matters. No matter how good an API, it won't get used without good documentation. Document every exported API element: every class, method, field, and parameter."
A contradiction, I think.
Re: Documentation...
by Kurt Christensen,
Your message is awaiting moderation. Thank you for participating in the discussion.
There are always contradictory principles in engineering. That's why design is a non-trivial activity.
Re: Documentation...
by Albert Hwang,
Your message is awaiting moderation. Thank you for participating in the discussion.
The first refers to documentation of the code that uses the API. The second refers to the documentation of the API itself. If the API is properly named, then the code that uses it does not require documentation.
For example, if your API had a method that parsed a string and removed all white spaces, 'trim' would be much better than 'parse'.
Converting use-case tests into examples in tutorials: code citing
by Peter Arrenbrecht,
Your message is awaiting moderation. Thank you for participating in the discussion.
I wrote a tool to cite snippets of Java source code into documentation for exactly this purpose. Supports omitting irrelevant detail and highlighting especially relevant parts.
You can see it in action in a largish project in that project's Quick Start example and all of the tutorial, as in this example.
I've read this before.
by Jasper Novotny,
Your message is awaiting moderation. Thank you for participating in the discussion.
These things are a lot in Jaroslav Tulach's new book. Only real difference is that 'diamonds' above are 'stars' there.
Re: I've read this before.
by Abel Avram,
Your message is awaiting moderation. Thank you for participating in the discussion.
Joshua Bloch's article is just a late follow-up of his presentation done in 2006 (www.infoq.com/presentations/effective-api-design). I hope you don't suspect Bloch plagiarizing Tulach.
Diamonds vs. stars
by Jaroslav Tulach,
Your message is awaiting moderation. Thank you for participating in the discussion.
There is a significant difference between diamonds and stars. While diamonds are said to be forever, nobody considers stars eternal. As such the allegories are not the same. They are in fact quite different. Read more...
Re: I've read this before.
by Rich Unger,
Your message is awaiting moderation. Thank you for participating in the discussion.
Whoa, I highly doubt anyone would ever suspect such a thing. Not least because Jaroslav's book is almost entirely devoted to disproving the last one: "API design is an art, not a science." He argues (convincingly, I think) that there are sound engineering principles which can be applied to design an API.
Re: I've read this before.
by Ilja Preuß,
Your message is awaiting moderation. Thank you for participating in the discussion.
So, are you saying that engineering is science, not art? ;)
A collection of resources on API design
by Christopher Bare,
Your message is awaiting moderation. Thank you for participating in the discussion.
I've collected a set of good resources on API design here:
digitheadslabnotebook.blogspot.com/2010/07/how-...