Skip to main content

Deriving Extract Method Refactoring Suggestions for Long Methods

  • Conference paper
  • First Online:
Software Quality. The Future of Systems- and Software Development (SWQD 2016)

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

Included in the following conference series:

Abstract

The extract method is a common way to shorten long methods in software development. Before developers can use tools that support the extract method, they need to invest time in identifying a suitable refactoring candidate. This paper addresses the problem of finding the most appropriate refactoring candidate for long methods written in Java. The approach determines valid refactoring candidates and ranks them using a scoring function that aims to improve readability and reduce code complexity. We use length and nesting reduction as complexity indicators. The number of parameters needed by the candidate influences the score. To suggest candidates that are consistent with the structure of the code, information such as comments and blank lines are also considered by the scoring function. We evaluate our approach to three open source systems using a user study with ten experienced developers. Our results show that they would actually apply 86 % of suggestions for an extract method refactoring.

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.

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.

    http://sourceforge.net/.

References

  1. Fowler, M.: Refactoring: Improving the Design of Existing Code. Addison-Wesley, Reading (1999)

    MATH  Google Scholar 

  2. Kanemitsu, T., Higo, Y., Kusumoto, S.: A visualization method of program dependency graph for identifying extract method opportunity. In: Proceedings of the 4th Workshop on Refactoring Tools, pp. 8–14. ACM (2011)

    Google Scholar 

  3. Marticorena, R., Lpez, C., Crespo, Y., Prez, F.J.: Refactoring generics in JAVA: a case study on extract method. In: 14th European Conference on Software Maintenance and Reengineering (CSMR), pp. 212–221. IEEE (2010)

    Google Scholar 

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

    Google Scholar 

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

    Google Scholar 

  6. Murphy-Hill, E., Black, A.P.: Why don’t people use refactoring tools?. In: Proceedings of the 1st Workshop on Refactoring Tools, pp. 60–61 (2007)

    Google Scholar 

  7. Murphy-Hill, E., Black, A.P.: Breaking the barriers to successful refactoring: observations and tools for extract method. In: Proceedings of the 30th International Conference on Software Engineering, pp. 421–430. IEEE (2008)

    Google Scholar 

  8. Opdyke, W.F.: Refactoring object-oriented frameworks. Ph.D. thesis. University of Illinois at Urbana-Champaign (1992)

    Google Scholar 

  9. Sharma, T.: Identifying extract-method refactoring candidates automatically. In: Proceedings of the 5th Workshop on Refactoring Tools, pp. 50–53. ACM (2012)

    Google Scholar 

  10. Silva, D., Terra, R., Valente, M.T.: Recommending automated extract method refactorings. In: Proceedings of the 22nd International Conference on Program Comprehension, pp. 146–156. ACM (2014)

    Google Scholar 

  11. Steidl, D., Eder, S.: Prioritizing maintainability defects based on refactoring recommendations. In: Proceedings of the 22nd International Conference on Program Comprehension, pp. 168–176. ACM (2014)

    Google Scholar 

  12. Streitel, F.: Incremental language independent static data flow analysis. Master’s thesis, Technical University of Munich (2014)

    Google Scholar 

  13. Tsantalis, N. Chatzigeorgiou, A.: Identification of extract method refactoring opportunities. In: 13th European Conference on Software Maintenance and Reengineering, pp. 119–128. IEEE (2009)

    Google Scholar 

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

    Google Scholar 

  15. Yang, L., Liu, H., Niu, Z.: Identifying fragments to be extracted from long methods. In: Asia-Pacific Software Engineering Conference, pp. 43–49. IEEE (2009)

    Google Scholar 

Download references

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

© 2016 Springer International Publishing Switzerland

About this paper

Cite this paper

Haas, R., Hummel, B. (2016). Deriving Extract Method Refactoring Suggestions for Long Methods. In: Winkler, D., Biffl, S., Bergsmann, J. (eds) Software Quality. The Future of Systems- and Software Development. SWQD 2016. Lecture Notes in Business Information Processing, vol 238. Springer, Cham. https://doi.org/10.1007/978-3-319-27033-3_10

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-27033-3_10

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-27032-6

  • Online ISBN: 978-3-319-27033-3

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics