Live Blogging from DrupalCon Chicago: Aphorisms of API Design

Presenter: Larry Garfield

  • A good example: noad_load_multiple: Wrapper by node_load in Drupal 7: It doesn't make a difference if you're loading 1 nore or 100 node
  • A not so good example: Search API. Only allows to search for one entity at one (i.e. the module doesn't allow the user to search for users and nodes)
  • Good APIs are picky: Instead of returning nothing / NULL, good APIs return exact error message (think of the "Invalid parameters supplied on line 2933 somewhere in forms.include"
  • In you rown module: don't use undocumented APIs and don't hardcode code that shouldn't be
  • A UI is not an API
  • A website is also not an API: An API does not need a website
  • 3 implementations should be required: 1. Simpletest. 2. Drush. 3. Webform