File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Assertions Doubts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Assertions Doubts" Watch "Assertions Doubts" New topic
Author

Assertions Doubts

Micheal John
Ranch Hand

Joined: Nov 01, 2006
Posts: 344
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 ]

Micheal John
SCJP 1.4 (86%), SCWCD 1.4 (86%), SCBCD 1.3 (85%), SCDJWS (Just Started...) - Satisfaction Lies in Our EFFORT, Not in the ATTAINMENT
Parambir Singh
Ranch Hand

Joined: Sep 05, 2004
Posts: 40

Can you post the complete question?


SCJP, SCMAD
Micheal John
Ranch Hand

Joined: Nov 01, 2006
Posts: 344
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..
 
Don't get me started about those stupid light bulbs.
 
subject: Assertions Doubts