All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----sdsu.test.Assert
Asset.condition( (X > 5 ) && ( Z <= 10 ));This asserts that the condition should be true at this point. If it is not an exception will be thrown. So the program can assume that the condition is true after the above assert.
In C/C++ ASSERT is defined as a macro. Thus the macro can be turned off with a compile switch. This allows the code to contain ASSERTS with out any runtime cost. There is no way in Java to completely eliminate the cost of the Assert calls. Hopefully future compilers will be smart enough to use tricks with classpaths and two versions of this class to "turn off" the Assert calls in productin code without modifing the program source.
See Writing Solid Code by Steve Maguire, pp 13-44 or Object-Oriented Software Construction by Bertrand Meyer, pp 111 - 163 for the use and importance of Assert.
public Assert()
public static void condition(boolean result)
public static void precondition(boolean result)
public static void postcondition(boolean result)
public static void classInvariant(boolean result)
All Packages Class Hierarchy This Package Previous Next Index