TUM CCSM Commons

Package edu.tum.cs.commons.assertion

This package provides support for precondition checking and assertions.

See:
          Description

Class Summary
CCSMAssert This class provides simple methods to implement assertions.
CCSMPre This class provides simple methods to check preconditions.
 

Exception Summary
PreconditionException This class is used to signal violations of preconditions
 

Package edu.tum.cs.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 CCSMPre class. Violations are signaled with 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.


TUM CCSM Commons

TUM CCSM Commons - 2.7