Skip navigation links

Package org.conqat.lib.commons.assertion

This package provides support for precondition checking and assertions.

See: Description

Package org.conqat.lib.commons.assertion Description

This package provides support for precondition checking and assertions.

Preconditions vs Assertions

To understand the difference between preconditions and assertions it is important do differentiate between the developer of a component (class, method, ...) and the user of this component.

Preconditions are used to signal violations of the usage contract of components to its user. These preconditions are usually documented as part of the component's comment. Examples: "Argument may not be null", "Argument must be positive", "cannot call x for empty list". Preconditions are checked using the methods of the org.conqat.lib.commons.assertion.CCSMPre class. Violations are signaled with org.conqat.lib.commons.assertion.PreconditionExceptions.

Assertions are used to check that invariants that only the developer of component knows are valid. These are used to check for implementation (opposed to usage) faults. Examples are: "Stack size cannot be negative.", "Array index must not be greater than array length". Assertions are checked using the methods of the CCSMAssert class. Violations are signaled with AssertionErrors.

Skip navigation links