Help Center

Local Navigation

Best practice: Writing efficient code

To allow a BlackBerry® Java® Application to use resources efficiently, consider the following guidelines:

  • Use local variables.
  • Use shorthand for evaluating Boolean conditions.
  • Make classes final.
  • Use int instead of long.
  • Avoid garbage collection.
  • Use static variables for Strings.
  • Avoid the String(String) constructor.
  • Write efficient loops.
  • Optimize subexpressions.
  • Optimize division operations.
  • Avoid java.util.Enumeration.
  • Perform casts using instanceof.
  • Evaluate conditions using instanceof.
  • Avoid using StringBuffer.append (StringBuffer).
  • Avoid returning null.
  • Avoid passing null into methods.
  • Use caution when passing null into a constructor.
  • Use long for unique identifiers.
  • Exit applications correctly.
  • Print the stack trace.

Index


Was this information helpful? Send us your comments.