"Extract Method" refactoring is a technique for consolidating code clones. Parameterization approaches are used to extract a single method from multiple code clones that contain differences. This approach parameterizes expressions and behaviors within a method. In particular, behavior parameterization has been extensively studied in Java programs, but little research has been conducted on other programming languages. Lambda expressions can be used to parameterize behaviors, but the specifications of each programming language significantly affect the applicability of this technique. Therefore, the optimal "Extract Method" approach may vary depending on the programming language. In this study, we propose a C#-specific technique that uses lambda expressions to analyze and consolidate code clones. We evaluated our proposed method by applying it to code clones detected by the NiCad clone detector and measuring how many of them could be successfully consolidated. In total, 2,217 clone pairs from 22 projects were included in our evaluation. For the clone pairs determined to be refactorable, we also attempted refactoring actually. The proposed approach determined that 35.0% of all clone pairs were suitable for refactoring. Among these, 28.9% were successfully refactored.


翻译:"提取方法"重构是一种用于整合代码克隆的技术。参数化方法被用于从包含差异的多个代码克隆中提取单一方法。该方法对方法内的表达式和行为进行参数化。特别是在Java程序中,行为参数化已得到广泛研究,但针对其他编程语言的研究却很少。Lambda表达式可用于参数化行为,但各编程语言的规范会显著影响该技术的适用性。因此,最优的"提取方法"策略可能因编程语言而异。在本研究中,我们提出了一种针对C#的特定技术,该技术利用Lambda表达式分析和整合代码克隆。我们通过将所提方法应用于NiCad克隆检测器发现的代码克隆,并测量其成功整合的比例来进行评估。评估共包含来自22个项目的2,217个克隆对。对于被判定为可重构的克隆对,我们还实际尝试了重构操作。所提出的方法判定全部克隆对中35.0%适合进行重构,其中28.9%成功完成了重构。

0
下载
关闭预览

相关内容

代码(Code)是专知网的一个重要知识资料文档板块,旨在整理收录论文源代码、复现代码,经典工程代码等,便于用户查阅下载使用。
IEEE TPAMI | 基于标注偏差估计的实例相关PU学习
专知会员服务
12+阅读 · 2021年10月23日
NAACL 2019 | 一种考虑缓和KL消失的简单VAE训练方法
PaperWeekly
20+阅读 · 2019年4月24日
基于PyTorch/TorchText的自然语言处理库
专知
28+阅读 · 2019年4月22日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2014年12月31日
国家自然科学基金
10+阅读 · 2014年12月31日
VIP会员
相关基金
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2014年12月31日
国家自然科学基金
10+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员