As tons of pages have been written about this topic, I don't want to reinvent the wheel but to have a list of common issues which I found in the projects were I worked is usefful.

Readability

  • Use constants: Don't use string twice in a class. In the Hybris eCommerce Platform attributes use the constants defined in the model class
  • Use Java Enumerations: For fields with a limited values. They use the cast mechanism to prevent many of the typical errors associated with constants. Use the Java Enumerations generated by the Hybris eCommerce Platform in the platform project.

Logging

  • In the production environments, Log4j is usually configured to send an email if there is a warning or an error. Don't log to System.out or System.err.

Error-Handling

  • Don't ignore exceptions using empty catch blocks. If you take action, you may ignore the error. In any other case, you should always inform the caller returning an object which contains some flag or property indicating the error.
  • Don't catch Exception or Throwable. We can't write handling code for any possible exception.

Add comment


Security code
Refresh