Major motivations for extract method refactorings: analysis based on interviews and change histories
Wenmei LIU, Hui LIU
Major motivations for extract method refactorings: analysis based on interviews and change histories
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 (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.
software refactoring / extract method / motivation / data mining / software quality
[1] |
Opdyke WF. Refactoring object-oriented frameworks. Dissertation for the Doctoral Degree. Champaign: University of Illinois at Urbana- Champaign, 1992
|
[2] |
Mens T, Tourwé T. A survey of software refactoring. IEEE Transactions on Software Engineering, 2004, 30(2): 126–139
CrossRef
Google scholar
|
[3] |
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
CrossRef
Google scholar
|
[4] |
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
CrossRef
Google scholar
|
[5] |
Maruyama K. Automated method-extraction refactoring by using block-based slicing. ACM SIGSOFT Software Engineering Notes, 2001, 26(3): 31–40
CrossRef
Google scholar
|
[6] |
Sharma T. Identifying extract-method refactoring candidates automatically. In: Proceedings of the 5thWorkshop on Refactoring Tools. 2012, 50–53
CrossRef
Google scholar
|
[7] |
Tsantalis N, Chatzigeorgiou A. Identification of extract method refactoring opportunities for the decomposition of methods. Journal of Systems and Software, 2011, 84: 1757–1782
CrossRef
Google scholar
|
[8] |
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
CrossRef
Google scholar
|
[9] |
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
CrossRef
Google scholar
|
[10] |
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
CrossRef
Google scholar
|
[11] |
Liu H, Guo X, Shao W Z. Monitor-based instant software refactoring. IEEE Transactions on Software Engineering, 2013, 39(8): 1112–1126
CrossRef
Google scholar
|
[12] |
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
CrossRef
Google scholar
|
[13] |
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
|
[14] |
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
CrossRef
Google scholar
|
[15] |
Murphy G C, Kersten M, Findlater L. How are Java software developers using the eclipse IDE? IEEE Software, 2006, 23(4): 76–83
CrossRef
Google scholar
|
[16] |
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
CrossRef
Google scholar
|
[17] |
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
CrossRef
Google scholar
|
[18] |
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
CrossRef
Google scholar
|
[19] |
Palomba F. Textual analysis for code smell detection. In: Proceedings of the 37th IEEE/ACM International Conference on Software Engineering. 2015, 769–771
CrossRef
Google scholar
|
[20] |
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
CrossRef
Google scholar
|
[21] |
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)
CrossRef
Google scholar
|
[22] |
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
CrossRef
Google scholar
|
[23] |
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
CrossRef
Google scholar
|
[24] |
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
CrossRef
Google scholar
|
[25] |
Xing Z, Stroulia E. Refactoring detection based on UMLDiff changefacts queries. In: Proceedings of the 13th Working Conference on Reverse Engineering. 2006, 263–274
|
[26] |
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
CrossRef
Google scholar
|
[27] |
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
CrossRef
Google scholar
|
[28] |
Broder A Z. On the resemblance and containment of documents. In: Proceedings of the Compression and Complexity of Sequences. 1997, 21–29
|
[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
CrossRef
Google scholar
|
[30] |
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
CrossRef
Google scholar
|
[31] |
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
|
[32] |
Malpohl G, Hunt J, Tichy W. Renaming detection. In: Proceedings of the 15th IEEE International Conference on Automated Software Engi neering. 2000, 73–80
CrossRef
Google scholar
|
[33] |
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
CrossRef
Google scholar
|
[34] |
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
CrossRef
Google scholar
|
[35] |
Koschke R. Survey of research on software clones. In: Koschke R, Merlo E, Walenstein A, eds. Duplication, Redundancy, and Similarity in Software. 2007
|
[36] |
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
CrossRef
Google scholar
|
[37] |
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
CrossRef
Google scholar
|
[38] |
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
|
[39] |
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
CrossRef
Google scholar
|
[40] |
Baxter I D, Yahin A, Moura L, Anna S M, Bier L. Clone detection using abstract syntax trees. In: Proceedings of the International Conference on Software Maintenance. 1998, 368–377
CrossRef
Google scholar
|
[41] |
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
CrossRef
Google scholar
|
[42] |
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
CrossRef
Google scholar
|
[43] |
Liu Y, Liu H. Automated detection of extract method refactorings. Technical Report. 2014
|
[44] |
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
CrossRef
Google scholar
|
/
〈 | 〉 |