elektra-contracts(7) contracts for plugins

Assertions

Contracts as introduced by Meyer define preconditions and postconditions on routines. Assertions handle these conditions by checking them before entering or after leaving a routine. Because most of this can happen only at run time, it often leaves the user alone with an exception.

Elektra goes a step further. Instead of exiting the normal control flow when a precondition is not met, it is the responsibility of a special plugin to handle the situation and make sure that the precondition is met afterwards. Sometimes this is not possible. In these cases, the plugins check the necessary conditions and return with error code when they are not met. As we will see, these situations do not occur very often.

Because of the modular approach, we can have several checkers, and correcting and checking can be combined. Plugins can work together to reach a certain goal.

KeySet and Key already handle most parts of checking pre- and postconditions imposed on data structures. Elektra's core provides preconditions and weak postconditions for the plugins.