Saturday, November 19, 2011

Appropriate use of Assertions

  • AssertionError is a sub class of Throwable, so it can be caught. But sun not doesnot allow access to the object that generated it. We only get a String message.
  • We should not use Assertions to validate arguments of a public method.
  • We can use Assertions to validate arguments of a private method.
  • We should not use Assertions to validate command line arguments.
  • We should use Assertions which doesnot leave the state of the program in the same state.

No comments:

Post a Comment