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

代码重复感知的重构实践对质量指标影响的实证研究

An Empirical Study on the Impact of Code Duplication-aware Refactoring Practices on Quality Metrics

Eman Abdullah AlOmar

AI总结:

本文通过分析128个开源Java项目中332个重构提交,实证研究了代码重复消除重构操作对设计质量指标的影响,发现多数指标能捕捉开发者去重意图,但部分指标未能完全反映。

摘要:

背景:代码重构被广泛认为是一种重要的软件工程实践,能够提高源代码的可理解性和可维护性。多项研究尝试通过挖掘软件仓库来检测重构活动,从而收集、分析软件项目中的重构实践,并获得可操作的数据驱动见解。目标:我们的目标是在文献中提出的各种质量模型中,识别出那些与开发者消除代码重复的愿景相一致的模型,即当开发者明确提到他们重构代码是为了改进这些质量模型时。方法:我们从128个开源Java项目中提取了一个包含332个重构提交的语料库,这些提交由开发者在日常变更中应用并记录。特别地,我们提取了32个结构指标,并据此识别出软件工程师所感知的代码重复消除提交及其对应的重构操作。此后,我们实证分析了这些重构操作对一组常见的、最先进的设计质量指标的影响。结果:对所得结果的统计分析表明:(i)一些最先进的指标能够捕捉开发者消除代码重复的意图;(ii)某些指标比其他指标更受重视。我们证实,各种结构指标能够有效表示代码重复,并对软件质量产生不同影响。一些指标有助于改进,而另一些指标可能导致退化。结论:与主要质量属性相关联的大多数映射指标成功捕捉了开发者消除代码重复的意图,这一点从提交信息中可以明显看出。然而,某些指标并未完全捕捉这些意图。

英文摘要:

Context: Code refactoring is widely recognized as an essential software engineering practice that improves the understandability and maintainability of source code. Several studies attempted to detect refactoring activities through mining software repositories, allowing one to collect, analyze, and get actionable data-driven insights about refactoring practices within software projects. Objective: Our goal is to identify, among the various quality models presented in the literature, the ones that align with the developer's vision of eliminating duplicates of code, when they explicitly mention that they refactor the code to improve them. Method: We extract a corpus of 332 refactoring commits applied and documented by developers during their daily changes from 128 open-source Java projects. In particular, we extract 32 structural metrics from which we identify code duplicate removal commits with their corresponding refactoring operations, as perceived by software engineers. Thereafter, we empirically analyze the impact of these refactoring operations on a set of common state-of-the-art design quality metrics. Results: The statistical analysis of the results obtained shows that (i) some state-of-the-art metrics are capable of capturing the developer's intention of removing code duplication; and (ii) some metrics are being more emphasized than others. We confirm that various structural metrics can effectively represent code duplication, leading to different impacts on software quality. Some metrics contribute to improvements, while others may lead to degradation. Conclusion: Most of the mapped metrics associated with the main quality attributes successfully capture developers' intentions for removing code duplicates, as is evident from the commit messages. However, certain metrics do not fully capture these intentions

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

↑