Skip to main content

Learning to Rank Extract Method Refactoring Suggestions for Long Methods

  • Conference paper
  • First Online:
Software Quality. Complexity and Challenges of Software Engineering in Emerging Technologies (SWQD 2017)

Part of the book series: Lecture Notes in Business Information Processing ((LNBIP,volume 269))

Included in the following conference series:

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.

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

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    www.conqat.org.

  2. 2.

    On http://cqse.eu/swqd17data we provide our rankings and the corresponding code bases from which we generated the refactoring candidates.

References

  1. 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)

    Google Scholar 

  2. Fowler, M.: Refactoring: Improving the Design of Existing Code. Addison-Wesley Object Technology Series. Addison-Wesley, Reading (1999)

    MATH  Google Scholar 

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

    Chapter  Google Scholar 

  4. Hang, L.: A short introduction to learning to rank. IEICE Trans. Inf. Syst. 94(10), 1854–1862 (2011)

    Google Scholar 

  5. Jrvelin, K., Keklinen, J.: IR evaluation methods for retrieving highly relevant documents. In: 23rd SIGIR (2000)

    Google Scholar 

  6. Kim, M., Zimmermann, T., Nagappan, N.: A field study of refactoring challenges and benefits. In: 20th International Symposium on the FSE (2012)

    Google Scholar 

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

    Google Scholar 

  8. Liu, T.-Y.: Learning to rank for information retrieval. Found. Trends Inf. Retrieval 3(3), 225–331 (2009)

    Article  Google Scholar 

  9. Martin, R.C.: Clean Code: A Handbook of Agile Software Craftsmanship. Robert C. Martin Series. Prentice Hall, Upper Saddle River (2009)

    Google Scholar 

  10. Mondal, M., Roy, C.K., Schneider, K.: Automatic ranking of clones for refactoring through mining association rules. In: CSMR-WCRE (2014)

    Google Scholar 

  11. Murphy-Hill, E., Black, A.P.: Breaking the barriers to successful refactoring: observations and tools for extract method. In: 30th ICSE (2008)

    Google Scholar 

  12. 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)

    Article  Google Scholar 

  13. Sammut, C. (ed.): Encyclopedia of Machine Learning. Springer, New York (2011)

    MATH  Google Scholar 

  14. 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)

    MathSciNet  MATH  Google Scholar 

  15. Wang, W., Godfrey, M.W.: Recommending clones for refactoring using design, context, and history. In: ICSME (2014)

    Google Scholar 

  16. Wilking, D., Kahn, U.F., Kowalewski, S.: An empirical evaluation of refactoring. e-Informatica 1(1), 27–42 (2007)

    Google Scholar 

  17. Xia, F., Liu, T.-Y., Wang, J., Zhang, W., Li, H.: Listwise approach to learning to rank: theory and algorithm. In: 25th ICML (2008)

    Google Scholar 

Download references

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

Authors

Corresponding author

Correspondence to Roman Haas .

Editor information

Editors and Affiliations

Rights and permissions

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

Publish with us

Policies and ethics