Java API code best practices

Best practices for working with Java™ API include reusing objects, catching and handling exceptions, through JUnits to test the code.

Reuse objects when possible
Java APIs are wrappers over internal product code. In many cases, calling a Java API method can cause queries to the database. Therefore, to reduce the number of database queries, reuse the objects when possible without creating the new object each time.
Watch for specific product behaviors
It is likely that the Java API inherits the same behavior as the product since Java APIs are a wrapper on the core product function.
Use JUnits to test your Java API code
If you use JUnits, you can run code coverage tools like Emma or IBM® InfoSphere® DataStage®.
Use standard Java best practices for coding with the Java API
Guidelines about using specific data structures in Java are equally relevant for Java API use.
Catch and handle exceptions
Because several of the exceptions are runtime exceptions, your code needs to catch them. You need to add handling code as needed. See the Javadoc for the exceptions that are thrown by each method.
Development and deployment of extension point classes
If you are using a single JAR file to deploy the extension point classes, it is a best practice to have one person that is designated as the 'build' specialist who is responsible for building and deploying the entire JAR file and doing the necessary system restarts.
For more information, see Javadoc section in the Reference.