Recommending Composite Refactorings for Smell Removal: Heuristics and Evaluation

  • Willian Oizumi PUC-Rio
  • Ana C. Bibiano PUC-Rio
  • Diego Cedrim Amazon
  • Anderson Oliveira PUC-Rio
  • Leonardo Sousa Carnegie Mellon University
  • Alessandro Garcia PUC-Rio
  • Daniel Oliveira PUC-Rio


Structural degradation is the process in which quality attributes of a system are negatively impacted. When due attention is not paid to structural degradation, the source code may also become difficult to change. Code smells are recurring structures in the source code that may represent structural degradation. Hence, there are many catalogs and techniques for supporting the removal of code smells through refactoring recommendations, which usually consist of single refactorings such as a Move Method or an Extract Method. However, single refactorings are often not enough for completely removing certain smell occurrences. Moreover, recent studies show that developers most often apply composite refactorings - i.e., sequences of two or more refactorings - for removing code smells. Despite showing the importance of performing composite refactorings, most studies do not provide information on which composite refactoring patterns are recurrent in practice. In this context, a previous study identified 35 smell removal patterns that are frequent across multiple open source systems. However, such study has not explored how the removal patterns could help developers to apply effective composite refactorings. Thus, in this work, we propose a suite of new recommendation heuristics to help developers in applying effective composite refactorings. These heuristics are intended to remove three code smell types, namely Complex Class, Feature Envy, and God Class. After designing the heuristics, we evaluated their effectiveness through a quasi-experiment. This evaluation was conducted with 12 software developers and 9 smelly Java classes. Results indicate that developers considered our heuristics effective or partially effective in more than 93% of the cases. In addition, the evaluation helped us to identify multiple factors that contribute to the acceptance or rejection of the refactoring recommendations. Based on these factors, we defined new guidelines for the effective recommendation of smell-removal composite refactorings.
Palavras-chave: code smells, refactoring heuristics, composite refactoring, composite refactoring patterns, refactoring recommendations, refactoring
OIZUMI, Willian; BIBIANO, Ana C.; CEDRIM, Diego; OLIVEIRA, Anderson; SOUSA, Leonardo; GARCIA, Alessandro; OLIVEIRA, Daniel. Recommending Composite Refactorings for Smell Removal: Heuristics and Evaluation. In: SIMPÓSIO BRASILEIRO DE ENGENHARIA DE SOFTWARE (SBES), 34. , 2020, Natal. Anais [...]. Porto Alegre: Sociedade Brasileira de Computação, 2020 .