Link Details

Link 1062471 thumbnail
User 1076293 avatar

By fabiankessler
via flowstopper.org
Published: Nov 08 2013 / 13:13

Analysis of whether I should use the assert statement or throw AssertionError directly.
  • 9
  • 1
  • 1183
  • 902

Comments

Add your comment
User 851745 avatar

Greg Brown replied ago:

0 votes Vote down Vote up Reply

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.

User 388907 avatar

MCII replied ago:

0 votes Vote down Vote up Reply

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

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.

Voters For This Link (9)



Voters Against This Link (1)



Java Performance Optimization
Written by: Pierre-Hugues Charbonneau
Featured Refcardz: Top Refcardz:
  1. Design Patterns
  2. OO JS
  3. Cont. Delivery
  4. Java EE7
  5. HTML5 Mobile
  1. Node.js
  2. Debugging JavaScript
  3. OO JS
  4. JSON
  5. Ajax