| Author |
Assertion
|
Younes Essouabni
Ranch Hand
Joined: Jan 13, 2002
Posts: 479
|
|
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?
|
Younes
By constantly trying one ends up succeeding. Thus: the more one fails the more one has a chance to succeed.
|
 |
Dirk Schreckmann
Sheriff
Joined: Dec 10, 2001
Posts: 7023
|
|
|
Sure. It's for debugging and testing.
|
[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
|
 |
Cindy Glass
"The Hood"
Sheriff
Joined: Sep 29, 2000
Posts: 8521
|
|
|
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.
|
"JavaRanch, where the deer and the Certified play" - David O'Meara
|
 |
Ravi Veera
Ranch Hand
Joined: Jun 23, 2001
Posts: 127
|
|
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
Joined: Jan 13, 2002
Posts: 479
|
|
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
|
 |
 |
|
|
subject: Assertion
|
|
|