Abstract
Extract method is one of the most popular software refactorings. However, little work has been done to investigate or validate the major motivations for such refactorings. Digging into this issue might help researchers to improve tool support for extract method refactorings, e.g., proposing better tools to recommend refactoring opportunities, and to select fragments to be extracted. To this end, we conducted an interview with 25 developers, and our results suggest that current reuse, decomposition of long methods, clone resolution, and future reuse are the major motivations for extract method refactorings.We also validated the results by analyzing the refactoring history of seven open-source applications. Analysis results suggest that current reuse was the primary motivation for 56% of extract method refactorings, decomposition of methods was the primary motivation for 28% of extract method refactorings, and clone resolution was the primary motivation for 16% of extract method refactorings. These findings might suggest that recommending extract method opportunities by analyzing only the inner structure (e.g., complexity and length) of methods alone would miss many extract method opportunities. These findings also suggest that extract method refactorings are often driven by current and immediate reuse. Consequently, how to recognize or predict reuse requirements timely during software evolution may play a key role in the recommendation and automation of extract method refactorings. We also investigated the likelihood for the extracted methods to be reused in future, and our results suggest that such methods have a small chance Received April 2, 2015; accepted November 10, 2015 E-mail: Liuhui08@bit.edu.cn (12%) to be reused in future unless the extracted fragment could be reused immediately in software evolution and extracting such a fragment can resolve existing clones at the same time.
Similar content being viewed by others
References
Opdyke WF. Refactoring object-oriented frameworks. Dissertation for the Doctoral Degree. Champaign: University of Illinois at Urbana-Champaign, 1992
Mens T, Tourwé T. A survey of software refactoring. IEEE Transactions on Software Engineering, 2004, 30(2): 126–139
Murphy-Hill E, Parnin C, Black A P. How we refactor, and how we know it. IEEE Trransactions on Softeare Engineering, 2012, 38(1): 5–18
Xing Z, Stroulia E. Refactoring practice: How it is and how it should be supported — an eclipse case study. In: Proceedings of IEEE International Conference on Software Maintenance. 2006, 458–468
Maruyama K. Automated method-extraction refactoring by using block-based slicing. ACM SIGSOFT Software Engineering Notes, 2001, 26(3): 31–40
Sharma T. Identifying extract-method refactoring candidates automatically. In: Proceedings of the 5thWorkshop on Refactoring Tools. 2012, 50–53
Tsantalis N, Chatzigeorgiou A. Identification of extract method refactoring opportunities for the decomposition of methods. Journal of Systems and Software, 2011, 84: 1757–1782
Silva D, Terra R, Valente M T. Recommending automated extract method refactorings. In: Proceedings of the 22nd International Conference on Program Comprehension. 2014, 146–156
Palomba F, Bavota G, Di Penta M, Oliveto R, De Lucia A. Do they really smell bad? a study on developers’ perception of bad code smells. In: Proceedings of the 2014 IEEE International Conference on Software Maintenance and Evolution. 2014, 101–110
Murphy-Hill E, Parnin C, Black A P. How we refactor, and how we know it. In: Proceedings of the 31st International Conference on Software Engineering. 2009, 287–297
Liu H, Guo X, Shao W Z. Monitor-based instant software refactoring. IEEE Transactions on Software Engineering, 2013, 39(8): 1112–1126
Niu N, Bhowmik T, Liu H, Niu Z. Traceability-enabled refactoring for managing just-in-time requirements. In: Proceedings of the 22nd IEEE International Requirements Engineering Conference. 2014, 133–142
Tsantalis N, Guana V, Stroulia E, Hindle A. A multidimensional empirical study on refactoring activity. In: Proceedings of the 2013 Conference of the Center for Advanced Studies on Collaborative Research. 2013, 132–146
Fowler M. Refactoring: improving the design of existing code. In: Wells D, Williams L, eds. Extreme Programming and Agile Methods —XP/Agile Universe 2002. 2002
Murphy G C, Kersten M, Findlater L. How are Java software developers using the eclipse IDE? IEEE Software, 2006, 23(4): 76–83
Kim M, Zimmermann T, Nagappan N. A field study of refactoring challenges and benefits. In: Proceedings of the 20th ACM SIGSOFT International Symposium on the Foundations of Software Engineering. 2012, 1–11
Bavota G, Lucia A D, Penta M D, Oliveto R, Palomba F. An experimental investigation on the innate relationship between quality and refactoring. Journal of Systems and Software, 2015, 107: 1–14
Palomba F, Bavota G, Penta M D, Oliveto R, Poshyvanyk D, Lucia A D. Mining version histories for detecting code smells. IEEE Transactions on Software Engineering, 2015, 41(5): 462–489
Palomba F. Textual analysis for code smell detection. In: Proceedings of the 37th IEEE/ACM International Conference on Software Engineering. 2015, 769–771
Bavota G, Oliveto R, Gethers M, Poshyvanyk D, De Lucia A. Methodbook: recommending move method refactorings via relational topic models. IEEE Transactions on Software Engineering, 2014, 40(7): 671–694
Bavota G, Gethers M, Oliveto R, Poshyvanyk D, de Lucia A. Improving software modularization via automated analysis of latent topics and dependencies. ACM Transactions on Software Engineering & Methodology, 2014, 23(1)
Bavota G, De Lucia A, Marcus A, Oliveto R. Automating extract class refactoring: an improved method and its evaluation. Empirical Software Engineering, 2014, 19(6): 1617–1664
Demeyer S, Ducasse S, Nierstrasz O. Finding refactorings via change metrics. In: Proceedings of the 15th ACM SIGPLAN Conference on Object-oriented Programming, Systems, Languages, and Applications. 2000, 166–177
Xing Z, Stroulia E. UMIDiff: an algorithm for object-oriented design differencing. In: Proceedings of the 20th IEEE/ACMInternational Conference on Automated Software Engineering. 2005, 54–65
Xing Z, Stroulia E. Refactoring detection based on UMLDiff changefacts queries. In: Proceedings of the 13th Working Conference on Reverse Engineering. 2006, 263–274
Weissgerber P, Diehl S. Identifying refactorings from source-code changes. In: Proceedings of the 21st IEEE/ACM International Conference on Automated Software Engineering. 2006, 231–240
Dig D, Comertoglu C, Marinov D, Johnson R. Automated detection of refactorings in evolving components. In: Proceedings of the 20th European Conference on Object-Oriented Programming. 2006, 404–428
Broder A Z. On the resemblance and containment of documents. In: Proceedings of the Compression and Complexity of Sequences. 1997, 21–29
Prete K, Rachatasumrit N, Sudan N, Kim M. Template-based reconstruction of complex refactorings. In: Proceedings of the 2010 IEEE International Conference on Software Maintenance. 2010, 1–10
Godfrey M, Zou L. Using origin analysis to detect merging and splitting of source code entities. IEEE Transactions on Software Engineering, 2005, 31(2): 166–181
Kim S, Pan K, Whitehead E. When functions change their names: automatic detection of origin relationships. In: Proceedings of the 12th Working Conference on Reverse Engineering. 2005, 143–152
Malpohl G, Hunt J, Tichy W. Renaming detection. In: Proceedings of the 15th IEEE International Conference on Automated Software Engineering. 2000, 73–80
Fluri B, Wursch M, Pinzger M, Gall H. Change distilling: tree differencing for fine-grained source code change extraction. IEEE Transactions on Software Engineering, 2007, 33(11): 725–743
Kim M, Notkin D, Grossman D. Automatic inference of structural changes for matching across program versions. In: Proceedings of the 29th International Conference on Software Engineering. 2007, 333–343
Koschke R. Survey of research on software clones. In: Koschke R, Merlo E, Walenstein A, eds. Duplication, Redundancy, and Similarity in Software. 2007
Wang T, Harman M, Jia Y, Krinke J. Searching for better configurations: a rigorous approach to clone evaluation. In: Proceedings of the 9th Joint Meeting on Foundations of Software Engineering. 2013, 455–465
Roy C K, Cordy J R, Koschke R. Comparison and evaluation of code clone detection techniques and tools: a qualitative approach. Science of Computer Programming, 2009, 74: 470–495
Jia Y, Binkley D, Harman M, Krinke J, Matsushita M. KClone: a proposed approach to fast precise code clone detection. In: Proceedings of the 3rd International Workshop on Software Clones. 2009
Balazinska M, Merlo E, Dagenais M, Lague B, Kontogiannis K. Advanced clone-analysis to support object-oriented system refactoring. In: Proceedings of the 7th Working Conference on Reverse Engineering. 2000, 98–107
Baxter ID, Yahin A, Moura L, Anna SM, Bier L. Clone detection using abstract syntax trees. In: Proceedings of the International Conference on Software Maintenance. 1998, 368–377
Canfora G, Cerulo L, Di Penta M. Ldiff: An enhanced line differencing tool. In: Proceedings of the 31st IEEE International Conference on Software Engineering. 2009, 595–598
Asaduzzaman M, Roy C, Schneider K, Di Penta M. Lhdiff: Tracking source code lines to support software maintenance activities. In: Proceedings of the 29th IEEE International Conference on Software Maintenance. 2013, 484–487
Liu Y, Liu H. Automated detection of extract method refactorings. Technical Report. 2014
Murphy-Hill E, Black A P, Dig D, Parnin C. Gathering refactoring data: a comparison of four methods. In: Proceedings of the 2nd Workshop on Refactoring Tools. 2008, 1–5
Author information
Authors and Affiliations
Corresponding author
Additional information
Wenmei Liu received the BS degree in control science from Shandong University, China in 2003, and the MS degree from Beihang University, China in 2006. She is currently working toward the PhD degree with the School of Computer Science and Technology at the Beijing Institute of Technology, China. Her research interests include software engineering, software refactoring, and software evolution.
Hui Liu received the BS degree in control science from Shandong University, China in 2001, theMS degree in computer science from Shanghai University, China in 2004, and the PhD degree in computer science from Peking University, China in 2008. He is currently an associate professor in the School of Computer Science and Technology at the Beijing Institute of Technology, China. He is particularly interested in software refactoring, design pattern, and software evolution. He is currently doing research to make software refactoring easier and safer. He is also interested in developing practical refactoring tools to assist software engineers.
Electronic supplementary material
Rights and permissions
About this article
Cite this article
Liu, W., Liu, H. Major motivations for extract method refactorings: analysis based on interviews and change histories. Front. Comput. Sci. 10, 644–656 (2016). https://doi.org/10.1007/s11704-016-5131-4
Received:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s11704-016-5131-4