MOTIVATIONS FOR APPLYING THE EXTRACT METHOD REFACTORING: A STUDY BASED ON COMMIT MESSAGES
Refactoring, Extract Method, Code metrics, Repository mining, Qualitative analysis.
Refactorings are operations performed on source code aimed at improving the maintainability of a software system. Although literature contains a high number of studies on refactorings, there are only few works that investigate the motivations reported by developers to perform refactorings. Therefore, this research aims to investigate the motivations behind extract method refactorings in real systems. To achieve this, we conducted two empirical studies: a preliminary study involving a single software system, and another study considering multiple real systems. The studies were based on mining software repository commits in which extract method refactorings occurred. Essentially, the goal was to analyze commit messages in order to capture developers' motivations for performing such refactorings. The results identified 16 different motivations for applying extract method. Additionally, it was observed that only 16% of the refactorings had an explicit intention of improving code quality. It was also identified that refactorings with the intention of improving code quality occurred more frequently in methods with size higher than 61 lines of code and less frequently in methods smaller than 20 lines of code.