Share this post! |
| Vote this! |
|
- Don't manage business logic with exceptions. Use conditional statements instead. If a control can be done with if-else statement clearly, don't use exceptions because it reduces readability and performance (e.g. null control, divide by zero control). .
- Exception names must be clear and meaningful, stating the causes of exception.
- Throw exceptions for error conditions while implementing a method. E.g. if you return -1, -2, -3 etc. values instead of FileNotFoundException, that method can not be understand.
- Catch specific exceptions instead of the top Exception class. This will bring additional performance, readability and more specific exception handling.
- Null control with conditionals is not an alternative to catching NullPointerException. If a method may return null, control it with if-else statement. If a return may throw NullPointerException, catch it. More...
Highly
Recommended Reading After Above
Programming
0 comments:
Post a Comment