Mining Motivations for Applying Extract Method: A Preliminary Study
Abstract
Refactorings are operations performed on source code to improve the software maintainability. The literature contains several studies on refactorings. However there are few studies that investigated the motivations for such refactorings to occur. Our research aims to investigate the motivations behind extract method operations in a real system. For this, we conducted an empirical study in which we mined extract method refactorings and analyzed commit messages in order to capture the motivations behind the refactorings. We also analyzed the relationship between refactorings and the number of lines of code (LOC) of the refactored methods. The results showed 11 different motivations for applying extract method. Furthermore, we also observed that only 35% of the refactorings were intended to improve code quality. We also identified that refactorings intended to improve code quality occurred more frequently in methods with LOC values in the range of 21 to 40 and were less frequent in methods with values between 61 to 80.
References
D. S. Cruzes and T. Dyba. 2011. Recommended Steps for Thematic Synthesis in Software Engineering. In 2011 International Symposium on Empirical Software Engineering and Measurement. 275–284. https://doi.org/10.1109/ESEM.2011.36
B. Du Bois, S. Demeyer, and J. Verelst. 2005. Does the "Refactor to Understand" reverse engineering pattern improve program comprehension?. In Ninth European Conference on Software Maintenance and Reengineering. 334–343. https://doi.org/10.1109/CSMR.2005.25
R. Eckart de Castilho, E. Mújdricza-Maydt, S. Muhie, S. Hartmann, I. Gurevych, A. Frank, and C. Biemann. 2016. AWeb-based Tool for the Integrated Annotation of Semantic and Syntactic Structures. The COLING 2016 Organizing Committee, Osaka, Japan, 76–84.
M. Fowler. 1999. Refactoring: Improving the Design of Existing Code. Addison-Wesley Longman Publishing Co., Inc., USA.
W. Liu and H. Liu. 2016. Major motivations for extract method refactorings: analysis based on interviews and change histories. Frontiers of Computer Science 10, 4 (2016), 644–656.
T. Mens and T. Tourwe. 2004. A survey of software refactoring. IEEE Transactions on Software Engineering 30, 2 (2004), 126–139. https://doi.org/10.1109/TSE.2004.1265817
E. Murphy-Hill, C. Parnin, and A. P. Black. 2012. How We Refactor, and How We Know It. IEEE Transactions on Software Engineering 38, 1 (2012), 5–18. https://doi.org/10.1109/TSE.2011.41
M. Paixão, A. Uchôa, A. C. Bibiano,D. Oliveira, A. Garcia, J. Krinke, and E. Arvonio. 2020. Behind the Intents: An In-Depth Empirical Study on Software Refactoring in Modern Code Review. In Proceedings of the 17th International Conference on Mining Software Repositories. Association for Computing Machinery, 12. https://doi.org/10.1145/3379597.3387475
S. Rebai, M. Kessentini, V. Alizadeh, O. Ben Sghaier, and R. Kazman. 2020. Recommending refactorings via commit message analysis. Information and Software Technology 126 (2020), 106332. https://doi.org/10.1016/j.infsof.2020.106332
D. Silva, N. Tsantalis, and M. T. Valente. 2016. Why We Refactor? Confessions of GitHub Contributors. In Proceedings of the 2016 24th ACM SIGSOFT International Symposium on Foundations of Software Engineering (Seattle, WA, USA) (FSE 2016). Association for Computing Machinery, New York, NY, USA, 858–870.
N. Tsantalis, A. Ketkar, and D. Dig. 2020. RefactoringMiner 2.0. IEEE Transactions on Software Engineering (2020), 1–1.
M. T. Valente. 2020. Engenharia de Software Moderna. Independente. https://engsoftmoderna.info/
