The Evolution of Contracts

H.-Christian Estler, Carlo A. Furia, Martín Nordio, Marco Piccioni, Bertrand Meyer · arXiv (Cornell University) · 2012

Contracts are a form of lightweight formal specification embedded in the program text. Being executable parts of the code, they encourage programmers to devote the proper attention to specifications and help maintain consistency between specification and implementation as the program evolves. For verification, contracts can be evaluated at run time, and hence support dynamic analysis. The present study investigates the connection between contracts and software evolution. Based on an extensive empirical analysis of 15 contract-equipped Eiffel and C# projects totaling 5900 revisions, it explores, among other questions: 1) how contracts change over time; 2) which kinds of contract element (preconditions, postconditions, class invariants) are used more often; 3) the relationship between code change and contract change frequencies; and 4) the role of inheritance in the process. It has found, among other results, that: the percentage of program elements that include contracts is above 33% for most projects and tends to be stable over time; there is no strong preference for a certain type of contract element; contracts are quite stable compared to implementations; and inheritance does not significantly affect qualitative trends of contract usage.

Read the paper · More papers on PaperTik