• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Assertions

 
Wilder C Rodrigues
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,
Could I use Assertions in my Assignment?
I think is great!
Best regards,
Wilder C. Rodrigues
Sun Certified Programmer for Java 2 - Platform 1.4
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11914
209
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Wilder,
I hope we can
There have been several places in the assignment where I have used assertions as the first line in an Exception handler to indicate that the scenario should never occur. It is great - the assertion effectively comments the code while actually doing something useful! I still have code afterwards to handle the exception, but the assertion makes it very clear to anyone reading my code what my opinion of the chances of the exception occuring are.
Funny though - I hated assertions in C - there was no way to switch them off (without a recompile), and they provided little help (unless you also had core dumps). But in Java they are cool.
Regards, Andrew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic