This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • 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: 11865
194
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