Skip to content
STIMSMITH

Contract-Oriented Programming

Concept WIKI v1 · 7/7/2026

Contract-oriented programming is a programming paradigm that associates programs with specifications expressed as contracts. In academic work, it has been used as the foundation for specification languages that combine contracts with finite state machines to drive automated testing.

Contract-Oriented Programming

Overview

Contract-oriented programming is a software development paradigm in which software components are described alongside explicit contracts that specify the obligations and benefits of interacting with them. These contracts typically define preconditions, postconditions, and invariants that govern the behavior of operations, allowing implementations and their specifications to be reasoned about in a unified framework.

Specification Languages Built on Contracts

Research in automated software engineering has explored using contract-oriented programming as a basis for formal specification languages. By extending the core idea of contracts with additional structuring concepts, these languages can express richer behavioral properties of software.

Extension with Finite State Machines

One notable extension combines the contract-oriented paradigm with finite state machines. This produces a specification language in which:

  • Each component is described by a set of contracts (pre/post-condition style specifications).
  • The dynamic behavior of the component is captured by a finite state machine that constrains the legal sequences of operations.
  • The combination enables symbolic reasoning about both individual method calls and full interaction scenarios.

This style of specification has been used as input to automated test case generation, where the goal is not only to produce valid arguments for individual methods but also to generate complete execution scenarios that respect the underlying state machine.

Applications

The primary application documented in the literature is automated testing:

  • Constraint-based test generation. Specifications written in a contract-oriented language extended with finite state machines can be animated symbolically, producing test cases and scenarios that satisfy the encoded constraints.
  • Full scenario synthesis. Beyond generating individual method arguments, the symbolic animation of the specification can produce complete sequences of calls that exercise realistic interaction paths through the finite state machine.
  • Flexible constraint solving. The approach supports constraint solving over integer and bounded domains as well as over arbitrary types, using mechanisms such as type builders to connect application-level type semantics with the underlying constraint satisfaction framework.

Related Concepts

  • Specification language. Contract-oriented programming has been used as the conceptual foundation upon which specification languages are constructed, particularly those that extend it with further constructs such as finite state machines for behavioral modeling.

See Also

References

  • Trabelsi, A., et al. A Constraint Logic Programming Approach to Automated Testing. In: Proceedings of the 20th International Conference on Logic Programming (ICLP 2004), Saint-Malo, France. Springer, 2004.

LINKED ENTITIES

1 links

CITATIONS

3 sources
3 citations
[1] A specification language has been built by extending contract-oriented programming with finite state machines. A Constraint Logic Programming Approach to Automated Testing
[2] Contract-oriented programming combined with finite state machines has been used to drive automated test case generation, including the synthesis of full test scenarios via symbolic animation of specifications. A Constraint Logic Programming Approach to Automated Testing
[3] The constraint solving framework used with contract-oriented specifications can operate over integer or bounded domains as well as arbitrary types, with type builders linking type semantics to the CSP framework. A Constraint Logic Programming Approach to Automated Testing