You are here : Home » knowledge exchange


Performance improvement techniques

Performance improvement techniques in Exceptions
  • In a catch block avoid using the generic class Exception. For each try block use specific catch blocks based on what can go wrong in your code
  • Whenever you are using a throws clause always use the specific subclass of Exception like FileNotFoundException rather than using throws Exception.
  • Always use the finally block to release the resources like a database connection, closing a file or socket connection etc. This prevents resource leaks even if an exception occurs.
  • Do not use Exception handling in loops. It is better to place loops inside try/catch blocks than vice versa. Here is an code snippet that gives bench mark.

Knowledge Exchange about Php Java, Asp.Net, SEO At Narola Infotech



Copyright © 2005-2012 Narola Infotech, Custom Software & Website Development Company | All Rights Reserved.

Find Us on