• 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

Assertions Doubts

 
Ranch Hand
Posts: 344
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All these quotes are taken from Dan site, in true/false pattern.
But I want to know what it is and how can we identify by seeing the code that assert has been used as to check control flow invairant/postcondition/precondition/class variant/internal variant


The assert statement is being used to check a control-flow invariant to verify that the control flow never reaches a point in the program.




The assert statement is being used to check a class invariant--something that must be true about each instance of the class




The assert statement is being used to check an internal invariant--something that the programmer assumes to be true at a particular point in the program




The assert statements are being used to check a precondition--something that must be true when the method is invoked.





The assert statement is being used to check a postcondition--something that must be true when the method completes successfully.



can anyone explain the above thing with coding? Whether assertion can be used to check control flow invariant, postcondition and precondition (all the three condition I don't know)

pls explain
[ December 15, 2006: Message edited by: Micheal John ]
 
Ranch Hand
Posts: 40
Android Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you post the complete question?
 
Micheal John
Ranch Hand
Posts: 344
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have understood the precondition/postcondition and control flow invariant.

But still to check class variant and internal variant is not clear:

For Class Variant


For Internal Variant


My Understanding :Control Flow Invariant Example is: if assert statement is used in the default area of the switch or else in if/else construct.

Precondition Example: assert statement will be the first statement of the method, which means while invoking this method itself some thing needs to true..

Postcondition Example: the assert statement will be at the end of the method, which means while returning some thing that needs to true.

Need more clarification on checking on class variant and internal variant..
 
My previous laptop never exploded like that. Read this tiny ad while I sweep up the shards.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic