Link Details

Link 1062471 thumbnail
User 1076293 avatar

By fabiankessler
Published: Nov 08 2013 / 13:13

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


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)

Apache Hadoop
Written by: Piotr Krewski
Featured Refcardz: Top Refcardz:
  1. Play
  2. Akka
  3. Design Patterns
  4. OO JS
  5. Cont. Delivery
  1. Play
  2. Java Performance
  3. Akka
  4. REST
  5. Java