arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1905.02050cs.SE
收藏

分析代码注释以提高程序理解力

Analyzing Code Comments to Boost Program Comprehension

Yusuke Shinyama, Yoshitaka Arahori, Katsuhiko Gondow

摘要:

我们正在尝试寻找源代码注释,帮助程序员理解源代码的重要部分。这样的例子之一是解释分配零作为"清除"缓冲区的一种方式。这样的注释对程序员来说是无价的,正确地识别它们将有很大的帮助。为了实现这一目标,我们开发了一种方法来发现源代码中的解释性代码注释。我们首先提出了11种不同的代码注释类别。然后,我们开发了一个基于决策树的分类器,可以识别解释性评论,准确率为60%,召回率为80%。我们分析了2,000个GitHub项目,这些项目都是用两种语言编写的:Java和Python。这个任务是新颖的,因为它关注于方法或函数中的微观注释("本地注释"),而不是之前关注于API或方法级注释的工作。我们还研究了如何在不同的项目中使用不同类别的注释。我们的主要发现是,有两种主要类型的评论:前置条件和后置条件。我们的研究结果还表明,许多英语代码注释具有一定的语法结构,在不同的项目中是一致的。

英文摘要:

We are trying to find source code comments that help programmers understand a nontrivial part of source code. One of such examples would be explaining to assign a zero as a way to "clear" a buffer. Such comments are invaluable to programmers and identifying them correctly would be of great help. Toward this goal, we developed a method to discover explanatory code comments in a source code. We first propose eleven distinct categories of code comments. We then developed a decision-tree based classifier that can identify explanatory comments with 60% precision and 80% recall. We analyzed 2,000 GitHub projects that are written in two languages: Java and Python. This task is novel in that it focuses on a microscopic comment ("local comment") within a method or function, in contrast to the prior efforts that focused on API- or method-level comments. We also investigated how different category of comments is used in different projects. Our key finding is that there are two dominant types of comments: preconditional and postconditional. Our findings also suggest that many English code comments have a certain grammatical structure that are consistent across different projects.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑