Contracts in Practice

  • H. -Christian Estler
  • Carlo A. Furia
  • Martin Nordio
  • Marco Piccioni
  • Bertrand Meyer
Conference paper

DOI: 10.1007/978-3-319-06410-9_17

Part of the Lecture Notes in Computer Science book series (LNCS, volume 8442)
Cite this paper as:
Estler H.C., Furia C.A., Nordio M., Piccioni M., Meyer B. (2014) Contracts in Practice. In: Jones C., Pihlajasaari P., Sun J. (eds) FM 2014: Formal Methods. FM 2014. Lecture Notes in Computer Science, vol 8442. Springer, Cham

Abstract

Contracts are a form of lightweight formal specification embedded in the program text. Being executable parts of the code, they encourage programmers to devote proper attention to specifications, and help maintain consistency between specification and implementation as the program evolves. The present study investigates how contracts are used in the practice of software development. Based on an extensive empirical analysis of 21 contract-equipped Eiffel, C#, and Java projects totaling more than 260 million lines of code over 7700 revisions, it explores, among other questions: 1) which kinds of contract elements (preconditions, postconditions, class invariants) are used more often; 2) how contracts evolve over time; 3) the relationship between implementation changes and contract changes; 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.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Copyright information

© Springer International Publishing Switzerland 2014

Authors and Affiliations

  • H. -Christian Estler
    • 1
  • Carlo A. Furia
    • 1
  • Martin Nordio
    • 1
  • Marco Piccioni
    • 1
  • Bertrand Meyer
    • 1
  1. 1.Software Engineering, Department of Computer ScienceETH ZurichSwitzerland

Personalised recommendations