函数头注释的悖论
The Paradox of Function Header Comments
AI总结:
本文通过调查367名开发者发现函数头注释存在“认可价值却不愿编写”的悖论,并提出基于签名相似性的无信息文档度量指标,在21,140个GitHub Python文件中验证了实际注释通常包含签名之外的额外信息。
摘要:
或许使用最广泛的代码文档形式是函数头注释。我们对367名开发者进行了一项大规模调查,以记录他们对这类文档的期望并描述实际实践情况。矛盾的是,我们发现开发者认可头注释的价值,并估计它们值得投入时间,但他们仍然倾向于不在自己的代码中编写此类文档。不编写头注释的原因各不相同,从认为代码应当自文档化,到担心文档无法保持最新。这种情况的一个可能结果是,开发者可能会通过使用模板生成毫无价值的注释来规避编写文档的要求,这些注释不提供任何真实信息。我们基于注释与函数签名的相似性,定义了一种用于衡量无信息文档的简单指标。将该指标应用于GitHub Python项目中的21,140个文件后表明,大多数函数没有文档,但当编写头注释时,它们通常确实包含函数签名之外的额外信息。
英文摘要:
Perhaps the most widely used form of code documentation is function header comments. We performed a large-scale survey of 367 developers to catalog their expectations from such documentation and to chronicle actual practice. Paradoxically, we found that developers appreciate the value of header comments and estimate that they are worth the investment in time, but nevertheless they tend not to write such documentation in their own code. Reasons for not writing header comments vary from the belief that code should be self-documenting to concern that documentation will not be kept up-to-date. A possible outcome of this situation is that developers may evade requirements to write documentation by using templates to generate worthless comments that do not provide any real information. We define a simple metric for information-less documentation based on its similarity to the function signature. Applying this to 21,140 files in GitHub Python projects shows that most functions are undocumented, but when header comments are written they typically do contain additional information beyond the function signature.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。