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

开发者讨论代码注释的哪些内容?

What Do Developers Discuss about Code Comments?

Pooja Rani, Mathias Birrer, Sebastiano Panichella, Mohammad Ghafari, Oscar Nierstrasz

AI总结:

本文通过 LDA 与人工分析 SO、Quora 上的代码注释讨论,构建问题分类体系,揭示开发者关注文档工具、注释语法、风格规范及自动化支持。

摘要:

代码注释对于程序理解、开发和维护任务十分重要。由于代码注释标准各不相同,且其具有非结构化或半结构化性质,开发者(尤其是新手开发者)很容易对应遵循哪些约定,或在编写代码文档时应使用哪些工具感到困惑。因此,他们会在外部在线来源发布相关问题,以寻求更好的注释实践。本文中,我们分析 Stack Overflow(SO)和 Quora 等在线来源上的代码注释讨论,以阐明开发者围绕注释实践提出的问题。我们应用 Latent Dirichlet Allocation(LDA)识别与代码注释有关的新兴主题。随后,我们对具有统计显著性的帖子样本集进行人工分析,得出一个分类体系,用于概览开发者关于注释实践的问题。结果表明,在 SO 上,近 40% 的问题提到如何在文档工具和环境中编写或处理注释,近 20% 的问题涉及文档工具在自动且一致地向注释中添加更多信息方面的潜在局限和可能性。另一方面,在 Quora 上,开发者问题更关注代码注释的背景信息(占问题的 35%)或征求相关意见(占问题的 16%)。我们发现:(i)编码风格指南并未覆盖注释的所有方面,例如如何添加特定类型的信息;(ii)开发者在学习用于向注释中添加各类信息的语法和格式约定方面需要支持;(iii)开发者对多种注释自动化策略感兴趣,例如检测不良注释或自动验证注释风格,但缺乏实现这些目标的工具支持。

英文摘要:

Code comments are important for program comprehension, development, and maintenance tasks. Given the varying standards for code comments, and their unstructured or semi-structured nature, developers get easily confused (especially novice developers) about which convention(s) to follow, or what tools to use while writing code documentation. Thus, they post related questions on external online sources to seek better commenting practices. In this paper, we analyze code comment discussions on online sources such as Stack Overflow (SO) and Quora to shed some light on the questions developers ask about commenting practices. We apply Latent Dirichlet Allocation (LDA) to identify emerging topics concerning code comments. Then we manually analyze a statistically significant sample set of posts to derive a taxonomy that provides an overview of the developer questions about commenting practices. Our results highlight that on SO nearly 40% of the questions mention how to write or process comments in documentation tools and environments, and nearly 20% of the questions are about potential limitations and possibilities of documentation tools to add automatically and consistently more information in comments. On the other hand, on Quora, developer questions focus more on background information (35% of the questions) or asking opinions (16% of the questions) about code comments. We found that (i) not all aspects of comments are covered in coding style guidelines, e.g., how to add a specific type of information, (ii) developers need support in learning the syntax and format conventions to add various types of information in comments, and (iii) developers are interested in various automated strategies for comments such as detection of bad comments, or verify comment style automatically, but lack tool support to do that.

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

↑