This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: A comparative study of programmer-written and automatically inferred contracts Nadia Polikarpova, Ilinca Ciupa, Bertrand Meyer Chair of Software Engineering, ETH Zurich, Switzerland [email protected] ABSTRACT Where do contracts — specification elements embedded in exe- cutable code — come from? To produce them, should we rely on the programmers, on automatic tools, or some combination? Recent work, in particular the Daikon system, has shown that it is possible to infer some contracts automatically from program executions. The main incentive has been an assumption that most programmers are reluctant to invent the contracts themselves. The experience of contract-supporting languages, notably Eiffel, dis- proves that assumption: programmers will include contracts if given the right tools. That experience also shows, however, that the resulting contracts are generally partial and occasionally incorrect. Contract inference tools provide the opportunity for studying ob- jectively the quality of programmer-written contracts, and for as- sessing the respective roles of humans and tools. Working on 25 classes taken from different sources such as widely-used standard libraries and code written by students, we applied Daikon to in- fer contracts and compared the results (totaling more than 19500 inferred assertion clauses) with the already present contracts. We found that a contract inference tool can be used to strengthen programmer-written contracts, but cannot infer all contracts that humans write. The tool generates around five times as many rel- evant contract elements (assertion clauses) as written by program- mers; but it only finds around 60% of those originally written by programmers. Around a third of the generated assertions clauses are either incorrect or irrelevant. The study also uncovered inter- esting correlations between the quality of inferred contracts and some code metrics. 1. INTRODUCTION Embedding contracts (executable specification elements) in soft- ware texts yields a number of benefits : contracts provide a basis for program verification techniques; they are essential for au- tomated testing strategies by helping to filter out invalid inputs and acting as automated oracles; they support debugging by providing information about the locations of faults; they serve as documen- tation aid; they enhance the analysis and design process. These diverse applications make contracts an invaluable tool in support of Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. To copy otherwise, to republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee....
View Full Document
This note was uploaded on 02/24/2012 for the course CSE 503 taught by Professor Davidnotikin during the Spring '11 term at University of Washington.
- Spring '11
- Software engineering