Skip to main content
Log in

Major motivations for extract method refactorings: analysis based on interviews and change histories

  • Research Article
  • Published:
Frontiers of Computer Science Aims and scope Submit manuscript

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.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Similar content being viewed by others

References

  1. Opdyke WF. Refactoring object-oriented frameworks. Dissertation for the Doctoral Degree. Champaign: University of Illinois at Urbana-Champaign, 1992

    Google Scholar 

  2. Mens T, Tourwé T. A survey of software refactoring. IEEE Transactions on Software Engineering, 2004, 30(2): 126–139

    Article  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

    Article  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

    Google Scholar 

  5. Maruyama K. Automated method-extraction refactoring by using block-based slicing. ACM SIGSOFT Software Engineering Notes, 2001, 26(3): 31–40

    Article  Google Scholar 

  6. Sharma T. Identifying extract-method refactoring candidates automatically. In: Proceedings of the 5thWorkshop on Refactoring Tools. 2012, 50–53

    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

    Article  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

    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

    Chapter  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

    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

    Article  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

    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

    Google Scholar 

  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

    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

    Article  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

    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

    Article  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

    Article  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

    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

    Article  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)

    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

    Article  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

    Chapter  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

    Chapter  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

    Google Scholar 

  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

    Chapter  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

    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

    Google Scholar 

  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

    Chapter  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

    Article  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

    Google Scholar 

  32. Malpohl G, Hunt J, Tichy W. Renaming detection. In: Proceedings of the 15th IEEE International Conference on Automated Software Engineering. 2000, 73–80

    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

    Article  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

    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

    Google Scholar 

  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

    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

    Article  MathSciNet  MATH  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

    Google Scholar 

  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

    Chapter  Google Scholar 

  40. 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

    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

    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

    Google Scholar 

  43. Liu Y, Liu H. Automated detection of extract method refactorings. Technical Report. 2014

    Google Scholar 

  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

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Hui Liu.

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

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

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

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s11704-016-5131-4

Keywords

Navigation