arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2409.09923cs.SE
收藏

理解代码变更:微变更视角

Understanding Code Change with Micro-Changes

Lei Chen, Michele Lanza, Shinpei Hayashi

AI总结:

针对代码差异难以理解的问题,本文提出基于微变更的方法,将差异转化为可自然语言描述的预定义操作,并开发自动检测器,在开源仓库中成功解释超过67%的条件逻辑相关变更。

摘要:

在软件维护与演化中,一项关键活动是理解开发者提交拉取请求和/或在代码仓库上执行提交时所进行的变更。通常,代码变更以代码差异(diff)的形式呈现,即突出显示两个文件版本之间差异的文本表示,描绘新增、删除和修改的行。这种简化的表示需要开发者自行解读,并在心智上提升至更高的抽象层次,使其更接近自然语言描述,从而便于建立对变更的心智模型。然而,基于文本差异的表示较为繁琐,且这种提升需要相当的领域知识和编程技能。我们提出了一种基于微变更概念的方法来克服这些困难,将代码差异转换为一系列预定义的变更操作,这些操作可以用自然语言描述。我们提供了一个微变更目录,并配套一个自动化的微变更检测器。为评估我们的方法,我们在大量开源代码仓库上进行了实证研究,重点关注我们微变更目录的一个子集,即与影响条件逻辑的变更相关的那些微变更。我们发现,我们的检测器能够解释所研究系统中超过67%的变更。

英文摘要:

A crucial activity in software maintenance and evolution is the comprehension of the changes performed by developers, when they submit a pull request and/or perform a commit on the repository. Typically, code changes are represented in the form of code diffs, textual representations highlighting the differences between two file versions, depicting the added, removed, and changed lines. This simplistic representation must be interpreted by developers, and mentally lifted to a higher abstraction level, that more closely resembles natural language descriptions, and eases the creation of a mental model of the changes. However, the textual diff-based representation is cumbersome, and the lifting requires considerable domain knowledge and programming skills. We present an approach, based on the concept of micro-change, to overcome these difficulties, translating code diffs into a series of pre-defined change operations, which can be described in natural language. We present a catalog of micro-changes, together with an automated micro-change detector. To evaluate our approach, we performed an empirical study on a large set of open-source repositories, focusing on a subset of our micro-change catalog, namely those related to changes affecting the conditional logic. We found that our detector is capable of explaining more than 67% of the changes taking place in the systems under study.

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

↑