Link Details

Analysis of whether I should use the assert statement or throw AssertionError directly.

Posted by fabiankessler  |   Nov 08 2013 / 13:13

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Comments

User 851745 avatar

Greg Brown replied ago:

Using assert instead throwing AssertionError is definitely the right choice. Errors are generally only meant to be thrown by the JVM itself, not by app code. For the default switch case, I generally throw UnsupportedOperationException.

Reply 0 votes
User 388907 avatar

MCII replied ago:

Of course you'd use non of them in real code. Typical blog post problem.

Reply 0 votes

Recommended Links

Scala
Written by: Ryan Knight
Featured Refcardz: Top Refcardz:
  1. Apache Hadoop
  2. Play
  3. Akka
  4. Debugging JavaScript
  5. Design Patterns
  1. Apache Hadoop
  2. REST
  3. Java
  4. Git
  5. Java Performance
Connect with DZone