What's the best way to code for extensions to work for multiple civicrm versions?
We have used the domain in some extensions, like so:

$civiVersion = CRM_Core_BAO_Domain::version();

if (version_compare($civiVersion, '4.5', '&lt;')) {
  //in CiviCRM 4.4 the invoke function has 5 arguments maximum
  return $hook-&gt;invoke($numParams, $arg1, $arg2, $arg3, $arg4, $arg5, $fnSuffix);
} else {
  //in CiviCRM 4.5 and later the invoke function has 6 arguments
  return $hook-&gt;invoke($numParams, $arg1, $arg2, $arg3, $arg4, $arg5, CRM_Utils_Hook::$_nullObject, $fnSuffix);
}