• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Assertion

 
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sure. It's for debugging and testing.
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic