Please wait a minute...
Frontiers of Computer Science

ISSN 2095-2228

ISSN 2095-2236(Online)

CN 10-1014/TP

Postal Subscription Code 80-970

2018 Impact Factor: 1.129

Front. Comput. Sci.    2016, Vol. 10 Issue (4) : 644-656    https://doi.org/10.1007/s11704-016-5131-4
RESEARCH ARTICLE
Major motivations for extract method refactorings: analysis based on interviews and change histories
Wenmei LIU,Hui LIU()
School of Computer Science and Technology, Beijing Institute of Technology, Beijing 100081, China
 Download: PDF(355 KB)  
 Export: BibTeX | EndNote | Reference Manager | ProCite | RefWorks
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 (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.

Keywords software refactoring      extract method      motivation      data mining      software quality     
Corresponding Author(s): Hui LIU   
Just Accepted Date: 12 November 2015   Online First Date: 12 June 2016    Issue Date: 06 July 2016
 Cite this article:   
Wenmei LIU,Hui LIU. Major motivations for extract method refactorings: analysis based on interviews and change histories[J]. Front. Comput. Sci., 2016, 10(4): 644-656.
 URL:  
https://academic.hep.com.cn/fcs/EN/10.1007/s11704-016-5131-4
https://academic.hep.com.cn/fcs/EN/Y2016/V10/I4/644
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
https://doi.org/10.1109/TSE.2004.1265817
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
https://doi.org/10.1109/TSE.2011.41
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
https://doi.org/10.1109/icsm.2006.52
5 Maruyama K. Automated method-extraction refactoring by using block-based slicing. ACM SIGSOFT Software Engineering Notes, 2001, 26(3): 31–40
https://doi.org/10.1145/379377.375233
6 Sharma T. Identifying extract-method refactoring candidates automatically. In: Proceedings of the 5thWorkshop on Refactoring Tools. 2012, 50–53
https://doi.org/10.1145/2328876.2328883
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
https://doi.org/10.1016/j.jss.2011.05.016
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
https://doi.org/10.1145/2597008.2597141
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
https://doi.org/10.1109/ICSME.2014.32
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
https://doi.org/10.1109/icse.2009.5070529
11 Liu H, Guo X, Shao W Z. Monitor-based instant software refactoring. IEEE Transactions on Software Engineering, 2013, 39(8): 1112–1126
https://doi.org/10.1109/TSE.2013.4
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
https://doi.org/10.1109/re.2014.6912255
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
https://doi.org/10.1007/3-540-45672-4_31
15 Murphy G C, Kersten M, Findlater L. How are Java software developers using the eclipse IDE? IEEE Software, 2006, 23(4): 76–83
https://doi.org/10.1109/MS.2006.105
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
https://doi.org/10.1145/2393596.2393655
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
https://doi.org/10.1016/j.jss.2015.05.024
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
https://doi.org/10.1109/TSE.2014.2372760
19 Palomba F. Textual analysis for code smell detection. In: Proceedings of the 37th IEEE/ACM International Conference on Software Engineering. 2015, 769–771
https://doi.org/10.1109/icse.2015.244
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
https://doi.org/10.1109/TSE.2013.60
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)
https://doi.org/10.1145/2559935
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
https://doi.org/10.1007/s10664-013-9256-x
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
https://doi.org/10.1145/353171.353183
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
https://doi.org/10.1145/1101908.1101919
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
https://doi.org/10.1109/ASE.2006.41
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
https://doi.org/10.1007/11785477_24
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
https://doi.org/10.1109/ICSM.2010.5609577
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
https://doi.org/10.1109/TSE.2005.28
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
https://doi.org/10.1109/ase.2000.873652
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
https://doi.org/10.1109/TSE.2007.70731
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
https://doi.org/10.1109/icse.2007.20
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
https://doi.org/10.1145/2491411.2491420
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
https://doi.org/10.1016/j.scico.2009.02.007
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
https://doi.org/10.1109/WCRE.2000.891457
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
https://doi.org/10.1109/icsm.1998.738528
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
https://doi.org/10.1109/icse.2009.5070564
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
https://doi.org/10.1109/icsm.2013.78
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
https://doi.org/10.1145/1636642.1636649
[1] FCS-0644-15131-HL_suppl_1 Download
[1] Genan DAI, Xiaoyang HU, Youming GE, Zhiqing NING, Yubao LIU. Attention based simplified deep residual network for citywide crowd flows prediction[J]. Front. Comput. Sci., 2021, 15(2): 152317-.
[2] Yuling MA, Chaoran CUI, Jun YU, Jie GUO, Gongping YANG, Yilong YIN. Multi-task MIML learning for pre-course student performance prediction[J]. Front. Comput. Sci., 2020, 14(5): 145313-.
[3] Guijuan ZHANG, Yang LIU, Xiaoning JIN. A survey of autoencoder-based recommender systems[J]. Front. Comput. Sci., 2020, 14(2): 430-450.
[4] Lu LIU, Shang WANG. Meta-path-based outlier detection in heterogeneous information network[J]. Front. Comput. Sci., 2020, 14(2): 388-403.
[5] Xu-Ying LIU, Sheng-Tao WANG, Min-Ling ZHANG. Transfer synthetic over-sampling for class-imbalance learning with limited minority class data[J]. Front. Comput. Sci., 2019, 13(5): 996-1009.
[6] Satoshi MIYAZAWA, Xuan SONG, Tianqi XIA, Ryosuke SHIBASAKI, Hodaka KANEDA. Integrating GPS trajectory and topics from Twitter stream for human mobility estimation[J]. Front. Comput. Sci., 2019, 13(3): 460-470.
[7] Shuaiqiang WANG, Yilong YIN. Polygene-based evolutionary algorithms with frequent pattern mining[J]. Front. Comput. Sci., 2018, 12(5): 950-965.
[8] Bo SUN, Haiyan CHEN, Jiandong WANG, Hua XIE. Evolutionary under-sampling based bagging ensemble method for imbalanced data classification[J]. Front. Comput. Sci., 2018, 12(2): 331-350.
[9] Yuan LI, Yuhai ZHAO, Guoren WANG, Xiaofeng ZHU, Xiang ZHANG, Zhanghui WANG, Jun PANG. Finding susceptible and protective interaction patterns in large-scale genetic association study[J]. Front. Comput. Sci., 2017, 11(3): 541-554.
[10] Junhua LU,Wei CHEN,Yuxin MA,Junming KE,Zongzhuang LI,Fan ZHANG,Ross MACIEJEWSKI. Recent progress and trends in predictive visual analytics[J]. Front. Comput. Sci., 2017, 11(2): 192-207.
[11] Chengliang WANG,Yayun PENG,Debraj DE,Wen-Zhan SONG. DPHK: real-time distributed predicted data collecting based on activity pattern knowledge mined from trajectories in smart environments[J]. Front. Comput. Sci., 2016, 10(6): 1000-1011.
[12] Xin XU,Wei WANG,Jianhong WANG. A three-way incremental-learning algorithm for radar emitter identification[J]. Front. Comput. Sci., 2016, 10(4): 673-688.
[13] Yaobin HE, Haoyu TAN, Wuman LUO, Shengzhong FENG, Jianping FAN. MR-DBSCAN: a scalable MapReduce-based DBSCAN algorithm for heavily skewed data[J]. Front. Comput. Sci., 2014, 8(1): 83-99.
[14] Fabian GIESEKE, Gabriel MORUZ, Jan VAHRENHOLD. Resilient k-d trees: k-means in space revisited[J]. Front Comput Sci, 2012, 6(2): 166-178.
[15] David Lorge PARNAS. The use of mathematics in software quality assurance[J]. Front Comput Sci, 2012, 6(1): 3-16.
Viewed
Full text


Abstract

Cited

  Shared   
  Discussed