Originally written in French. Translated by AI — the meaning has been preserved, not the prose.
Short definition
A business rule that holds in every state of an object, whatever operations it goes through.
Full definition
In computing, an invariant is a condition a program keeps true at given points in its execution. In the articles on this blog, the term refers to a business rule stated in one sentence about a domain object — an invoice, a credit note, an order — and recorded in the ontology, independently of the code that enforces it.
Usage in the field
Writing a business ontology, deriving automated tests from rules, checking the consistency of code produced by an agent.
Synonyms and variants
Always-true rule, business constraint.
Not to be confused with
- Conditional business rule — a rule that only applies in certain cases or certain states; an invariant applies in all of them.
- Test — an executable check of a behaviour; an invariant can produce one, but exists without it.
Examples
A confirmed invoice can no longer be modified. An invoice has at least one line. A credit note references the invoice it corrects. A cancelled order cannot be shipped.
Ambiguities / debates
The boundary between an invariant and a conditional rule depends on how the states are divided: "a confirmed invoice can no longer be modified" is conditional with respect to the invoice, but invariant with respect to the "confirmed" state.