Glossary · Automation software engineering and architecture
Interface contract
Also known as: Design by contract, API contract
German: Schnittstellenvertrag
In software engineering, an interface contract is the explicit specification of the mutual obligations between a component and its users at an interface, including preconditions the caller must meet, postconditions and guarantees the component provides, invariants, error behavior and timing.
- Software engineering
In one sentence
An interface contract specifies the obligations at an interface: caller preconditions, provider guarantees, error behavior and timing.
Example
The contract of the 'MoveAbsolute' method states that the axis must be enabled and homed, that the target must be within the soft limits, and that 'Done' is set only after the position is reached.
Explained in context
Context cards connect this term with others to answer one question. Also in British English and German.
How it applies
- Engineering: Contracts make assumptions explicit. They can be written as documentation, checked at runtime with assertions, or tested with contract tests between services. Design by contract formalizes this approach.
- Integration: Many integration defects are contract violations: a caller that does not meet a precondition, or a component that does not deliver what callers assumed. A written contract settles which side must change.
- Documentation: Reference documentation for APIs and function blocks is the natural place for contracts: for each operation, state preconditions, effects, return values, errors, timing and side effects. The documentation team can help turn implicit assumptions from developers into clear contract statements.
Interface contract vs. interface specification
An Interface specification describes the whole interface, including data structures and protocols. The contract is the part that defines behavior and obligations. In systems engineering, an Interface control document (ICD) plays a similar role between subsystems and suppliers.