• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Assertion

 
Younes Essouabni
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I went through the sun's explanation, and other links provided in javaranch.
For what I understand, the only interest of assertion is debugging. If Your program fails to execute, it will throw an AssertionException, so you will know where it fails to execute!
Am I right, or does it have more goals?
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure. It's for debugging and testing.
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One of the primary tenets of Asserts is that when they are not invoked (like in a production execution) they have a zero impact on execution. They were only intended to be brought into play during testing. This means that you can throw in as many zillion of them as you want - and leave them in the final code - but not worry about how they impact the performance.
 
Ravi Veera
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Asserts are part a important part of a programming and design technique known as "Programming By Contract".
Asserts were first part of the Eifel language. Here's a couple links that will explain these concepts much better than I can.
http://www.eiffel.com/doc/manuals/technology/contract/page.html
http://www.eiffel.com/doc/manuals/technology/contract/ariane/page.html.
I do also remember reading a article on XP v/s programming by contract. XP and programming by contract take diametrically opposite approaches to writing code.
Briefly ,The points made were
-XP -minimal intial designcode for success and the code is your documentation and design.
-Programming by contract. Detailed Design,you code only according to design(contract) and your code covers both successes and failures.
Maybe somebody can throw some more light on the XP v/s programming by contract topic .
Ravi
P.S Here's a couple of more intresting links on the topic.
http://www.scism.sbu.ac.uk/law/Section5/chap1/s5c1p4.html
A collection of links on java and programming by contract stuff..
http://www.geocities.com/Eureka/5855/java.htm
[ April 25, 2002: Message edited by: Ravi Veeraghanta ]
 
Younes Essouabni
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thx everybody for your help, everybody confirms that assertions is a debuging tool. But does it have other interest aspect?
I never heard this term :"programming by contract". I am going to find more information about it.
Thx for the help and the good links
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic