Abstract
Extract method refactoring is a common way to shorten long methods in software development. It improves code readability, reduces complexity, and is one of the most frequently used refactorings. Nevertheless, sometimes developers refrain from applying it because identifying an appropriate set of statements that can be extracted into a new method is error-prone and time-consuming.
In a previous work, we presented a method that could be used to automatically derive extract method refactoring suggestions for long Java methods, that generated useful suggestions for developers. The approach relies on a scoring function that ranks all valid refactoring possibilities (that is, all candidates) to identify suitable candidates for an extract method refactoring that could be suggested to developers. Even though the evaluation has shown that the suggestions are useful for developers, there is a lack of understanding of the scoring function. In this paper, we present research on the single scoring features, and their importance for the ranking capability. In addition, we evaluate the ranking capability of the suggested scoring function, and derive a better and less complex one using learning to rank techniques.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
Notes
- 1.
- 2.
On http://cqse.eu/swqd17data we provide our rankings and the corresponding code bases from which we generated the refactoring candidates.
References
Cao, Z., Qin, T., Liu, T.-Y., Tsai, M.-F., Li, H.: Learning to rank: from pairwise approach to listwise approach. In: 24th ICML (2007)
Fowler, M.: Refactoring: Improving the Design of Existing Code. Addison-Wesley Object Technology Series. Addison-Wesley, Reading (1999)
Haas, R., Hummel, B.: Deriving extract method refactoring suggestions for long methods. In: Winkler, D., Biffl, S., Bergsmann, J. (eds.) SWQD 2016. LNBIP, vol. 238, pp. 144–155. Springer, Heidelberg (2016). doi:10.1007/978-3-319-27033-3_10
Hang, L.: A short introduction to learning to rank. IEICE Trans. Inf. Syst. 94(10), 1854–1862 (2011)
Jrvelin, K., Keklinen, J.: IR evaluation methods for retrieving highly relevant documents. In: 23rd SIGIR (2000)
Kim, M., Zimmermann, T., Nagappan, N.: A field study of refactoring challenges and benefits. In: 20th International Symposium on the FSE (2012)
Lan, Y., Zhu, Y., Guo, J., Niu, S., Cheng, X.: Position-aware ListMLE: a sequential learning process for ranking. In: 30th Conference on UAI (2014)
Liu, T.-Y.: Learning to rank for information retrieval. Found. Trends Inf. Retrieval 3(3), 225–331 (2009)
Martin, R.C.: Clean Code: A Handbook of Agile Software Craftsmanship. Robert C. Martin Series. Prentice Hall, Upper Saddle River (2009)
Mondal, M., Roy, C.K., Schneider, K.: Automatic ranking of clones for refactoring through mining association rules. In: CSMR-WCRE (2014)
Murphy-Hill, E., Black, A.P.: Breaking the barriers to successful refactoring: observations and tools for extract method. In: 30th ICSE (2008)
Qin, T., Liu, T.-Y., Xu, J., Li, H.: Letor: a benchmark collection for research on learning to rank for information retrieval. Inf. Retrieval 13(4), 346–374 (2010)
Sammut, C. (ed.): Encyclopedia of Machine Learning. Springer, New York (2011)
Tsochantaridis, I., Joachims, T., Hofmann, T., Altun, Y.: Large margin methods for structured and interdependent output variables. J. Mach. Learn. Res. 6, 1453–1484 (2005)
Wang, W., Godfrey, M.W.: Recommending clones for refactoring using design, context, and history. In: ICSME (2014)
Wilking, D., Kahn, U.F., Kowalewski, S.: An empirical evaluation of refactoring. e-Informatica 1(1), 27–42 (2007)
Xia, F., Liu, T.-Y., Wang, J., Zhang, W., Li, H.: Listwise approach to learning to rank: theory and algorithm. In: 25th ICML (2008)
Acknowledgments
Thanks to the anonymous reviewers for their helpful feedback. This work was partially funded by the German Federal Ministry of Education and Research (BMBF), grant “Q-Effekt, 01IS15003A”. The responsibility for this article lies with the authors.
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2017 Springer International Publishing AG
About this paper
Cite this paper
Haas, R., Hummel, B. (2017). Learning to Rank Extract Method Refactoring Suggestions for Long Methods. In: Winkler, D., Biffl, S., Bergsmann, J. (eds) Software Quality. Complexity and Challenges of Software Engineering in Emerging Technologies. SWQD 2017. Lecture Notes in Business Information Processing, vol 269. Springer, Cham. https://doi.org/10.1007/978-3-319-49421-0_4
Download citation
DOI: https://doi.org/10.1007/978-3-319-49421-0_4
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-49420-3
Online ISBN: 978-3-319-49421-0
eBook Packages: Computer ScienceComputer Science (R0)