GetDunne Wiki

Notes from the desk of Shane Dunne, software development consultant

User Tools

Site Tools


api_guessing_game

This is an old revision of the document!


The API Guessing Game

Some day I intend to write an eloquent essay on the virtues of good software documentation, particularly as it applies to software libraries for use by other programmers. For the moment, I will say only this:

  • Once one achieves a basic level of coding competence, programming mainly involves choosing appropriate libraries, understanding their APIs, and debugging.
  • All three aspects require good documentation above all.
  • Good API documentation requires exactly two things:
    1. Working client code
    2. Explanation of how the API is supposed to be used
  • Most API documentation has neither, and as a result, programming becomes an exercise in guessing the intent of the library/API authors. I call this the API Guessing Game.

Elements of the API Guessing Game

  • Having to write code “experimentally” for one specific function call, and run it repeatedly to observe whether or not it works, what the return values are, etc., because the authors didn't bother to write it down.
  • Having no idea how to start implementing an operation using the library.
  • Having no which parts of the library are fundamental and unlikely to change, as opposed to those which are still under development.
  • Having high confidence that a specific class (or group of functions and data structures) is the right one for a specific purpose, but having no idea of the order in which the various functions are supposed to be called.

Documentation hints for library developers/vendors

  • The greatest library/API design in the world is no use if programmers can't figure out how to use it.
  • A few cryptic comments, processed through Doxygen, are not sufficient.
  • “Kitchen-sink” demo code (one giant demo app) is not nearly as useful as multiple smaller demos. (But one kitchen-sink demo is better than nothing.)
  • “Toy” examples (tiny demo apps which don't achieve anything of practical interest) are not nearly as helpful as examples that show the specific things that almost all of your users need to do.
  • FAQs and Forums are useful only to the extent that they are searchable.
  • If I have to search FAQs and Forums to figure out how to do something basic, which I know every other user will need to do, you're doing it wrong.
  • Code examples (including code which is generated by any code-generation tools you provide) must represent your recommended coding style and order of operations.
api_guessing_game.1506799413.txt.gz · Last modified: 2017/09/30 19:23 by shane