Skip to main content
QUICK REVIEW

[论文解读] Recommending Extract Method Refactoring Based on Confidence of Predicted Method Name

Jinto Yamanaka, Yasuhiro Hayase|arXiv (Cornell University)|Aug 25, 2021
Software Engineering Research参考文献 28被引用 5
一句话总结

本文提出了一种新颖的方法,通过利用 code2seq(一种先进的代码到名称模型)对方法名称预测的置信度分数,来推荐 Extract Method 重构。通过将此置信度度量与 GEMS 中现有的度量指标相结合,该方法显著提升了推荐的正确性,其中 code2seq 置信度成为最重要的特征,相较于基线技术,F-measure 和覆盖率均有所提高。

ABSTRACT

Refactoring is an important activity that is frequently performed in software development, and among them, Extract Method is known to be one of the most frequently performed refactorings. The existing techniques for recommending Extract Method refactoring calculate metrics from the source method and the code fragments to be extracted to order the recommendation candidates. This paper proposes a new technique for accurately recommending Extract Method refactoring by considering whether code fragments are semantically coherent chunks that can be given clear method names, in addition to the metrics used in previous studies. As a criterion for the semantic coherency, the proposed technique employs the probability (i.e. confidence) of the predicted method names for the code fragments output by code2seq, which is a state-of-the-art method name prediction technique. The evaluation experiment confirmed that the proposed technique has higher correctness of recommendation than the existing techniques.

研究动机与目标

  • 通过整合代码片段的语义一致性,提升 Extract Method 重构推荐的准确性。
  • 解决现有技术忽略提取代码是否可被语义命名的局限性。
  • 评估方法名称预测置信度是否与重构适用性相关。
  • 在最先进的 GEMS 框架中引入基于置信度的过滤机制,以提升推荐的精确率与召回率。

提出的方法

  • 所提出的方法使用 code2seq 对候选代码片段进行方法名称预测,并提取最高预测结果的置信度分数。
  • 将置信度分数作为新特征,与 GEMS 中使用的传统度量指标(如内聚度、复杂度等)相结合。
  • 该模型将置信度与 TYPEDELE_COHESION、INVOCATION_COHESION 和 RATIO_LOC 等现有特征结合,用于对重构候选进行排序。
  • 该技术作为 GEMS 的扩展实现,采用 XGBoost 进行分类与特征重要性分析。
  • 基于真实重构数据构建正样本与负样本,用于模型的训练与评估。
  • 通过特征重要性分析,评估置信度相对于其他度量指标的贡献。

实验结果

研究问题

  • RQ1将 code2seq 预测的置信度纳入模型,是否能提升 Extract Method 重构推荐的正确性?
  • RQ2预测方法名称的置信度分数与代码片段的语义一致性之间是否存在相关性?
  • RQ3在推荐模型中,置信度相对于传统重构度量指标的相对贡献如何?
  • RQ4置信度分数是否能有效区分可行与不可行的重构候选?

主要发现

  • 所提出的技术在所有容差水平下均实现了高于 GEMS 的 F-measure,证实了推荐正确性的提升。
  • code2seq 置信度(CODE2SEQ_CONFIDENCE)成为最重要的特征,其重要性得分为 0.30011,显著优于其次重要的特征。
  • 正样本(已重构)的平均置信度为 0.063695,高于负样本的平均值 0.011233,表明可行候选具有更好的语义一致性。
  • 正样本的中位数置信度(0.0036578)高于负样本(0.00000049674),进一步支持置信度的区分能力。
  • 模型的召回率提升幅度超过精确率,表明置信度有效扩展了推荐重构目标的覆盖范围。
  • 置信度在预测中发挥了显著作用,体现在其在特征重要性排名中的主导地位以及持续的性能提升。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。