Refactoring effect on internal quality attributes: What haven't they told you yet?

Eduardo Fernandes*, Alexander Chávez, Alessandro Garcia, Isabella Ferreira, Diego Cedrim, Leonardo Sousa, Willian Oizumi

*Corresponding author for this work

Research output: Contribution to journalJournal articleResearchpeer-review


Context: Code refactoring was conceived for enhancing code structures, often in terms of internal quality attributes such as cohesion and coupling. Developers may have to apply multiple refactoring operations to achieve the expected enhancement. Re-refactoring occurs whenever one or more refactoring operations are performed on a previously refactored code element. The literature often assumes each single refactoring improves rather than worsens internal quality attributes, while re-refactoring implies further improvements. Unfortunately, quantitative evidence on this matter is scarce if not nonexistent. Objective: This paper extends a large quantitative study about the refactoring effect on internal quality attributes with new insights, plus an unprecedented re-refactoring effect analysis. We particularly investigate if re-refactoring operations are more effective in improving attributes when compared to single operations. Method: We analyzed 23 open software projects with 29,303 refactoring operations, from which nearly 50% constitute re-refactorings. We assessed five attributes: cohesion, complexity, coupling, inheritance, and size. We combined descriptive analysis and statistical tests to deeply understand the effect of both refactoring and re-refactoring on each attribute. Results: Contrary to current knowledge, our study revealed that 90% of refactoring operations, and 100% of re-refactoring operations, were applied to code elements with at least one critical attribute. Critical attribute is an attribute whose metrics used for computing it have anomalous values, e.g. high coupling. Most operations (65%) improve attributes presumably associated with the refactoring type applied; the other operations (35%) keep those attributes unaffected. Whenever refactoring and re-refactoring operations are applied without additional changes, i.e., root-canal refactoring, attributes tend to improve or at least not worsen. Surprisingly, if these operations occur with additional changes such as feature additions, i.e., floss refactoring, they mostly improve rather than worsen attributes. Conclusions: Besides revealing the effect of refactoring and re-refactoring on each attribute, we derived insights on leveraging the current refactoring practices.
Original languageEnglish
Article number106347
JournalInformation and Software Technology
Publication statusPublished - Oct 2020
Externally publishedYes


Dive into the research topics of 'Refactoring effect on internal quality attributes: What haven't they told you yet?'. Together they form a unique fingerprint.

Cite this