Table of Contents
Fetching ...

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

Eman Abdullah AlOmar

TL;DR

This study investigates how code duplication-aware refactoring aligns with software design quality metrics. Using a three-phase design, it builds a gold set of 322 commits documenting duplicate removal from 128 open-source Java projects and computes 32 structural metrics mapped to five quality attributes. Statistical analysis (Wilcoxon tests and Cliff’s delta) reveals that several metrics reflect developers’ intents—especially cohesion, coupling, complexity, and design size—yet some metrics diverge, highlighting limitations in capturing duplication-removal benefits. The findings support using a subset of metrics as features for refactoring recommendations while emphasizing the need for developer-in-the-loop tooling and a taxonomy of duplication-aware practices. Overall, the work contributes empirical evidence on which design metrics best mirror real-world duplicate-removal efforts and how refactoring choices impact perceived software quality.

Abstract

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

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

TL;DR

This study investigates how code duplication-aware refactoring aligns with software design quality metrics. Using a three-phase design, it builds a gold set of 322 commits documenting duplicate removal from 128 open-source Java projects and computes 32 structural metrics mapped to five quality attributes. Statistical analysis (Wilcoxon tests and Cliff’s delta) reveals that several metrics reflect developers’ intents—especially cohesion, coupling, complexity, and design size—yet some metrics diverge, highlighting limitations in capturing duplication-removal benefits. The findings support using a subset of metrics as features for refactoring recommendations while emphasizing the need for developer-in-the-loop tooling and a taxonomy of duplication-aware practices. Overall, the work contributes empirical evidence on which design metrics best mirror real-world duplicate-removal efforts and how refactoring choices impact perceived software quality.

Abstract

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

Paper Structure

This paper contains 14 sections, 11 figures, 5 tables.

Figures (11)

  • Figure 1: Overview of the empirical study design, highlighting the 3 main phases: Dataset Extraction, Selection of Quality Attributes and Software Metrics, and Data Analysis.
  • Figure 2: Cohesion - LCOM5
  • Figure 4: Boxplots of coupling metric values of pre- and post-refactored files.
  • Figure 5: Boxplots of complexity metric values of pre- and post-refactored files.
  • Figure 6: Boxplots of inheritance metric values of pre- and post-refactored files.
  • ...and 6 more figures