一句话:通过实证统计发现代码可验证性与人类可理解性仅呈弱正相关(r=0.23)。
软件验证的支持者认为更简单的代码更易验证,即验证工具误报更少、所需人工干预更少,但该假设缺乏实证。作者将四个先进验证工具在211个Java代码片段上产生的警告数量,与六项先前研究中人类受试者给出的20种代码可理解性度量进行比较,并进行统计(元)分析。结果显示,总体可理解性与可验证性之间存在小但显著的相关性(r=0.23),支持易验证代码通常也更易理解的观点。该工作对验证工具用户与设计者以及自动度量代码可理解性的未来尝试具有启示:验证工具可能对可理解性有附带收益,而度量可理解性可能需要考虑语义而非仅语法属性。
Proponents of software verification have argued that simpler code is easier to verify: that is, that verification tools issue fewer false positives and require less human intervention when analyzing simpler code. We empirically validate this assumption by comparing the number of warnings produced by four state-of-the-art verification tools on 211 snippets of Java code with 20 metrics of code comprehensibility from human subjects in six prior studies. Our experiments, based on a statistical (meta-)analysis, show that, in aggregate, there is a small correlation (r = 0.23) between understandability and verifiability. The results support the claim that easy-to-verify code is often easier to understand than code that requires more effort to verify. Our work has implications for the users and designers of verification tools and for future attempts to automatically measure code comprehensibility: verification tools may have ancillary benefits to understandability, and measuring understandability may require reasoning about semantic, not just syntactic, code properties.