Skip to main content
Log in

Feature requests-based recommendation of software refactorings

  • Published:
Empirical Software Engineering Aims and scope Submit manuscript

Abstract

Software requirements are ever-changing which often leads to software evolution. Consequently, throughout software lifetime, developers receive new requirements often expressed as feature requests. To implement the requested features, developers sometimes apply refactorings to make their systems adapt to the new requirements. However, deciding what refactorings to apply is often challenging and there is still lack of automated support to recommend refactorings given a feature request. To this end, we propose a learning-based approach that recommends refactorings based on the history of the previously requested features, applied refactorings, and code smells information. First, the state-of-the-art refactoring detection tools are leveraged to identify the previous refactorings applied to implement the past feature requests. Second, a machine classifier is trained with the history data of the feature requests, code smells, and refactorings applied on the respective commits. Consequently, the machine classifier is used to predict refactorings for new feature requests. The proposed approach is evaluated on the dataset of 55 open source Java projects and the results suggest that it can accurately recommend refactorings (accuracy is up to 83.19%).

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.

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Fig. 6
Fig. 7

Similar content being viewed by others

References

  • Aggarwal CC, Zhai C (2012) A survey of text classification algorithms. In: Zhai C (ed) Aggarwal CC. Springer, Mining text data, pp 163–222

  • AlOmar EA, Mkaouer MW, Ouni A (2019) Can refactoring be self-affirmed?: An exploratory study on how developers document their refactoring activities in commit messages. In: Tsantalis N, Cai Y, Demeyer S (eds) Proceedings of the 3rd international workshop on refactoring, IWOR@ICSE 2019, Montreal, QC, Canada, May 28, 2019. IEEE/ACM, pp 51–58

  • Alspaugh TA, Scacchi W (2013) Ongoing software development without classical requirements. In: 21st IEEE International requirements engineering conference, RE 2013, Rio de Janeiro-RJ, Brazil, July 15–19, 2013. IEEE Computer Society, pp 165–174

  • Angerer F, Grimmer A, Prähofer H, Grünbacher P (2019) Change impact analysis for maintenance and evolution of variable software systems. Autom Softw Eng 26(2):417–461

    Article  Google Scholar 

  • Apache Projects Issues (2020) (Retrived on 12th March 2020). In: https://issues.apache.org/jira/projects/

  • Bavota G, Lucia AD, Marcus A, Oliveto R (2014) Recommending refactoring operations in large software systems. In: Robillard MP, Maalej W, Walker RJ, Zimmermann T (eds) Recommendation systems in software engineering. Springer, pp 387–419

  • Bavota G, Lucia AD, Marcus A, Oliveto R (2014) Automating extract class refactoring: an improved method and its evaluation. Empir Softw Eng 19 (6):1617–1664

    Article  Google Scholar 

  • Bugzilla (2019) (Accessed October 2019) https://www.bugzilla.org/

  • Chaparro O, Bavota G, Marcus A, Penta MD (2014) On the impact of refactoring operations on code quality metrics. In: 30th IEEE International conference on software maintenance and evolution, Victoria, BC, Canada, September 29–October 3, 2014, pp 456–460

  • Chen J, Huang H, Tian S, Qu Y (2009) Feature selection for text classification with naïve bayes. Expert Syst Appl 36(3):5432–5435

    Article  Google Scholar 

  • Codacy (2019) (Accessed October 2019) https://github.com/marketplace/codacy

  • Feng W, Sun J, Zhang L, Cao C, Yang Q (2016) A support vector machine based naive bayes algorithm for spam filtering. In: 35th IEEE international performance computing and communications conference, IPCCC 2016, Las Vegas, NV, USA, December 9–11, 2016, pp 1–8

  • Fokaefs M, Tsantalis N, Chatzigeorgiou A (2007) Jdeodorant: Identification and removal of feature envy bad smells. In: ICSM 2007. IEEE International conference on software maintenance 2007. IEEE, pp 519–520

  • Fokaefs M, Tsantalis N, Stroulia E, Chatzigeorgiou A (2011) Jdeodorant: identification and application of extract class refactorings. In: Proceedings of the 33rd international conference on software engineering, ICSE 2011, Waikiki, Honolulu , HI, USA, May 21–28, 2011, pp 1037–1039

  • Fokaefs M, Tsantalis N, Stroulia E, Chatzigeorgiou A (2012) Identification and application of extract class refactorings in object-oriented systems. J Syst Softw 85(10):2241–2260

    Article  Google Scholar 

  • Fowler M (1999) Refactoring—improving the design of existing code. Addison Wesley object technology series. Addison-Wesley

  • Gibaja E, Ventura S (2015) A tutorial on multilabel learning. ACM Comput Surv 47(3):52:1–52:38

    Article  Google Scholar 

  • Git Bash Commands (2018) (Retrived on 28th November 2018). In: https://www.atlassian.com/git

  • GitHub (2019) (Accessed October 2019) https://github.com/features

  • Godbole S, Sarawagi S (2004) Discriminative methods for multi-labeled classification. In: Dai H, Srikant R, Zhang C (eds) Advances in knowledge discovery and data mining, 8th Pacific-Asia Conference, PAKDD 2004, Sydney, Australia, May 26-28, 2004, Proceedings, Springer, Lecture Notes in Computer Science, vol 3056, pp 22–30

  • Heck P, Zaidman A (2013) An analysis of requirements evolution in open source projects: recommendations for issue trackers. In: 13th International workshop on principles of software evolution, IWPSE 2013, Proceedings, August 19–20, 2013, Saint Petersburg, pp 43–52

  • Hegedüs P, Kádár I, Ferenc R, Gyimóthy T (2018) Empirical evaluation of software maintainability based on a manually validated refactoring dataset. Inf Softw Technol 95:313–327

    Article  Google Scholar 

  • Jayatilleke S, Lai R, Reed K (2018) A method of requirements change analysis. Requir Eng 23(4):493–508

    Article  Google Scholar 

  • Jiang L, Cai Z, Zhang H, Wang D (2013) Naive bayes text classifiers: a locally weighted learning approach. J Exp Theor Artif Intell 25(2):273–286

    Article  Google Scholar 

  • JIRA (2019) (Accessed October 2019) https://www.atlassian.com/software/jira

  • Kessentini M, Dea TJ, Ouni A (2017) A context-based refactoring recommendation approach using simulated annealing: two industrial case studies. In: Proceedings of the genetic and evolutionary computation conference, GECCO 2017, Berlin, Germany, July 15–19, 2017, pp 1303–1310

  • Khan A, Baharudin B, Lee LH, Khan K, Tronoh UTP (2010) A review of machine learning algorithms for text-documents classification. J Adv Inf Technol 1(1):4–20

    Google Scholar 

  • Kim M, Gee M, Loh A, Rachatasumrit N (2010) Ref-finder: a refactoring reconstruction tool based on logic query templates. In: Proceedings of the 18th ACM SIGSOFT international symposium on foundations of software engineering, 2010, Santa Fe, NM, USA, November 7–11, 2010, pp 371–372

  • Kim M, Zimmermann T, Nagappan N (2012) A field study of refactoring challenges and benefits. In: 20th ACM SIGSOFT symposium on the foundations of software engineering (FSE-20), SIGSOFT/FSE’12, Cary, NC, USA–November 11–16, 2012, p 50

  • Lin Y, Peng X, Cai Y, Dig D, Zheng D, Zhao W (2016) Interactive and guided architectural refactoring with search-based recommendation. In: Proceedings of the 24th ACM SIGSOFT international symposium on foundations of software engineering, FSE 2016, Seattle, WA, USA, November 13–18, 2016, pp 535–546

  • Liu H, Ma Z, Shao W, Niu Z (2012) Schedule of bad smell detection and resolution: a new way to save effort. IEEE Trans Software Eng 38 (1):220–235

    Article  Google Scholar 

  • Liu H, Guo X, Shao W (2013) Monitor-based instant software refactoring. IEEE Trans Softw Eng 39(8):1112–1126

    Article  Google Scholar 

  • Liu H, Xu Z, Zou Y (2018) Deep learning based feature envy detection. In: Proceedings of the 33rd ACM/IEEE international conference on automated software engineering, ASE 2018, Montpellier, France, September 3–7, 2018, pp 385–396

  • Loper E, Bird S (2002) NLTK: the natural language toolkit. In: ACL workshop effective tools and methodologies for teaching on natural language processing and computational linguistics (ETMTNLP), pp 63–70

  • Mahmoud A, Niu N (2014) Supporting requirements to code traceability through refactoring. Requir Eng 19(3):309–329

    Article  Google Scholar 

  • Manning CD, Schütze H (2001) Foundations of statistical natural language processing. MIT Press, Cambridge

    MATH  Google Scholar 

  • Manning CD, Raghavan P, Schütze H (2008) Introduction to information retrieval. Cambridge University Press, Cambridge

    Book  Google Scholar 

  • Mei H, Zhang L (2018) Can big data bring a breakthrough for software automation? Science China Inf Sci 61(5):056101:1–056101:3

    Article  Google Scholar 

  • Mens T, Tourwé T (2004) A survey of software refactoring. IEEE Trans Softw Eng 30(2):126–139

    Article  Google Scholar 

  • Moha N, Guéhéneuc Y, Duchien L, Meur AL (2010) DECOR: a method for the specification and detection of code and design smells. IEEE Trans Softw Eng 36(1):20–36

    Article  Google Scholar 

  • Mohan M, Greer D (2018) A survey of search-based refactoring for software maintenance. J Softw Eng R&D 6:3

    Google Scholar 

  • Murphy-Hill ER, Parnin C, Black AP (2012) How we refactor, and how we know it. IEEE Trans Software Eng 38(1):5–18

    Article  Google Scholar 

  • Nizamani ZA, Liu H, Chen DM, Niu Z (2018) Automatic approval prediction for software enhancement requests. Autom Softw Eng 25(2):347–381

    Article  Google Scholar 

  • Niu N, Bhowmik T, Liu H, Niu Z (2014) Traceability-enabled refactoring for managing just-in-time requirements. In: IEEE 22nd international requirements engineering conference, RE 2014, Karlskrona, Sweden, August, 25–29, 2014, pp 133–142

  • Nyamawe AS, Liu H, Niu Z, Wang W, Niu N (2018) Recommending refactoring solutions based on traceability and code metrics. IEEE Access 6:49460–49475

    Article  Google Scholar 

  • Nyamawe AS, Liu H, Niu N, Umer Q, Niu Z (2019) Automated recommendation of software refactorings based on feature requests. In: Damian D E, Perini A, Lee S (eds) 27th IEEE International requirements engineering conference, RE 2019, Jeju Island, Korea (South), September 23–27, 2019. IEEE , pp 187–198

  • Ouni A, Kessentini M, Sahraoui HA, Hamdi MS (2013) The use of development history in software refactoring using a multi-objective evolutionary algorithm. In: Genetic and evolutionary computation conference, GECCO ’13, Amsterdam, The Netherlands, July 6–10, 2013, pp 1461–1468

  • Ouni A, Kessentini M, Sahraoui HA, Inoue K, Hamdi MS (2015) Improving multi-objective code-smells correction using development history. J Syst Softw 105:18–39

    Article  Google Scholar 

  • Ouni A, Kessentini M, Sahraoui HA, Inoue K, Deb K (2016) Multi-criteria code refactoring using search-based software engineering: an industrial case study. ACM Trans Softw Eng Methodol 25(3):23:1–23:53

    Article  Google Scholar 

  • Ouni A, Kessentini M, Cinnéide MÓ, Sahraoui HA, Deb K, Inoue K (2017) MORE: a multi-objective refactoring recommendation approach to introducing design patterns and fixing code smells. J Softw: Evol Process 29(5)

  • Palomba F, Salza P, Ciurumelea A, Panichella S, Gall HC, Ferrucci F, Lucia AD (2017) Recommending and localizing change requests for mobile apps based on user reviews. In: Uchitel S, Orso A, Robillard M P (eds) Proceedings of the 39th international conference on software engineering, ICSE 2017, Buenos Aires, Argentina, May 20–28, 2017. IEEE/ACM, pp 106–117

  • Palomba F, Zaidman A, Oliveto R, Lucia AD (2017) An exploratory study on the relationship between changes and refactoring. In: Proceedings of the 25th international conference on program comprehension, ICPC 2017, Buenos Aires, Argentina, May 22–23, 2017, pp 176–185

  • Pantiuchina J, Bavota G, Tufano M, Poshyvanyk D (2018) Towards just-in-time refactoring recommenders. In: Proceedings of the 26th conference on program comprehension, ICPC 2018, Gothenburg, Sweden, May 27–28, 2018, pp 312–315

  • PMDCodacy (2019) (Accessed October 2019) https://github.com/codacy/codacy-pmdjava

  • Porter MF (2006) An algorithm for suffix stripping. Program 40 (3):211–218

    Article  Google Scholar 

  • Rath M, Rendall J, Guo JLC, Cleland-Huang J, Mäder P (2018) Traceability in the wild: automatically augmenting incomplete trace links. In: Chaudron M, Crnkovic I, Chechik M, Harman M (eds) Proceedings of the 40th international conference on software engineering, ICSE 2018, Gothenburg, Sweden, May 27–June 03, 2018. ACM, pp 834–845

  • Ratzinger J, Sigmund T, Vorburger P, Gall HC (2007) Mining software evolution to predict refactoring. In: Proceedings of the first international symposium on empirical software engineering and measurement, ESEM 2007, September 20–21, 2007, Madrid, pp 354–363

  • Runeson P, Alexandersson M, Nyholm O (2007) Detection of duplicate defect reports using natural language processing. In: 29th International conference on software engineering (ICSE 2007), Minneapolis, MN, USA, May 20–26, 2007. IEEE Computer Society, pp 499–510

  • Schapire RE, Singer Y (2000) Boostexter: a boosting-based system for text categorization. Mach Learn 39(2/3):135–168

    Article  Google Scholar 

  • Scikit-learn (Accessed October 2019) https://scikit-learn.org/stable/

  • Silva D, Tsantalis N, Valente MT (2016) Why we refactor? Confessions of GitHub contributors. In: Proceedings of the 24th ACM SIGSOFT international symposium on foundations of software engineering, FSE 2016, Seattle, WA, USA, November 13–18, 2016, pp 858–870

  • Silva D, Valente MT (2017) Refdiff: detecting refactorings in version histories. In: Proceedings of the 14th international conference on mining software repositories, MSR 2017, Buenos Aires, Argentina, May 20–28, 2017, pp 269–279

  • Simon F, Steinbrückner F, Lewerentz C (2001) Metrics based refactoring. In: Fifth conference on software maintenance and reengineering, CSMR 2001, Lisbon, Portugal, March 14–16, 2001, pp 30–38

  • Soares G, Catao B, Varjao C, Aguiar S, Gheyi R, Massoni T (2011) Analyzing refactorings on software repositories. In: 25th Brazilian symposium on software engineering, SBES 2011, Sao Paulo, Brazil, September 28–30, 2011. IEEE Computer Society, pp 164–173

  • Sun C, Lo D, Wang X, Jiang J, Khoo S (2010) A discriminative model approach for accurate duplicate bug report retrieval. In: Kramer J, Bishop J, Devanbu P T, Uchitel S (eds) Proceedings of the 32nd ACM/IEEE international conference on software engineering—volume 1, ICSE 2010, Cape Town, South Africa, 1–8 May 2010. ACM, pp 45–54

  • Tan L, Bockisch C (2019) A survey of refactoring detection tools. In: Krusche S, Schneider K, Kuhrmann M, Heinrich R, Jung R, Konersmann M, Schmieders E, Helke S, Schaefer I, Vogelsang A, Annighöfer B, Schweiger A, Reich M, van Hoorn A (eds) Proceedings of the workshops of the software engineering conference 2019, Stuttgart, Germany, February 19, 2019, CEUR-WS.org, CEUR Workshop Proceedings, vol 2308, pp 100–105

  • Terra R, Valente MT, Miranda S, Sales V (2018) JMove: a novel heuristic and tool to detect move method refactoring opportunities. J Syst Softw 138:19–36

    Article  Google Scholar 

  • Thung F, Wang S, Lo D, Lawall JL (2013) Automatic recommendation of API methods from feature requests. In: 2013 28th IEEE/ACM international conference on automated software engineering, ASE 2013, Silicon Valley, CA, USA, November 11–15, 2013, pp 290–300

  • Thung F, Kochhar PS, Lo D (2014) Dupfinder: integrated tool support for duplicate bug report detection. In: Crnkovic I, Chechik M, Grünbacher P (eds) ACM/IEEE international conference on automated software engineering, ASE ’14, Vasteras, Sweden–September 15–19, 2014. ACM, pp 871–874

  • Tsantalis N, Chatzigeorgiou A (2009) Identification of move method refactoring opportunities. IEEE Trans Softw Eng 35(3):347–367

    Article  Google Scholar 

  • Tsantalis N, Chatzigeorgiou A (2011) Ranking refactoring suggestions based on historical volatility. In: 15th European conference on software maintenance and reengineering, CSMR 2011, 1–4 March, 2011, Oldenburg, pp 25–34

  • Tsantalis N, Mansouri M, Eshkevari LM, Mazinanian D, Dig D (2018) Accurate and efficient refactoring detection in commit history. In: Proceedings of the 40th international conference on software engineering, ICSE 2018, Gothenburg, Sweden, May 27–June 03, 2018, pp 483–494

  • Uysal AK, Günal S (2014) The impact of preprocessing on text classification. Inf Process Manag 50(1):104–112

    Article  Google Scholar 

  • Vidal SA, Marcos CA, Pace JAD (2014) An approach to prioritize code smells for refactoring. Autom Softw Eng 23(3):501–532

    Article  Google Scholar 

  • Xu S, Sivaraman A, Khoo S, Xu J (2017) GEMS: an extract method refactoring recommender. In: 28th IEEE International symposium on software reliability engineering, ISSRE 2017, Toulouse, France, October 23–26, 2017, pp 24–34

  • Yue R, Gao Z, Meng N, Xiong Y, Wang X, Morgenthaler J D (2018) Automatic clone recommendation for refactoring based on the present and the past. In: 2018 IEEE international conference on software maintenance and evolution, ICSME 2018, Madrid, Spain, September 23–29, 2018, pp 115–126

  • Zhang M, Zhou Z (2014) A review on multi-label learning algorithms. IEEE Trans Knowl Data Eng 26(8):1819–1837

    Article  Google Scholar 

Download references

Acknowledgements

The authors would like to say thanks to the anonymous reviewers of this manuscript as well as to the program chairs and the anonymous reviewers of RE’19 conference for their insightful comments and constructive suggestions. This work is partially supported by the National Natural Science Foundation of China (No. 61772071 and No. 61690205), and the U.S. National Science Foundation Award (CCF-1350487).

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Hui Liu.

Additional information

Communicated by: Kelly Blincoe, Daniela Damian, and Anna Perini

Publisher’s note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

This article belongs to the Topical Collection: Requirements Engineering

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Nyamawe, A.S., Liu, H., Niu, N. et al. Feature requests-based recommendation of software refactorings. Empir Software Eng 25, 4315–4347 (2020). https://doi.org/10.1007/s10664-020-09871-2

Download citation

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s10664-020-09871-2

Keywords

Navigation