DOI QR코드

DOI QR Code

A Systematic Literature Survey of Software Metrics, Code Smells and Refactoring Techniques

  • Agnihotri, Mansi (University School of Information, Communication & Technology (USIC&T), Guru Gobind Singh Indraprastha University) ;
  • Chug, Anuradha (University School of Information, Communication & Technology (USIC&T), Guru Gobind Singh Indraprastha University)
  • Received : 2020.01.16
  • Accepted : 2020.04.28
  • Published : 2020.08.31

Abstract

Software refactoring is a process to restructure an existing software code while keeping its external behavior the same. Currently, various refactoring techniques are being used to develop more readable and less complex codes by improving the non-functional attributes of software. Refactoring can further improve code maintainability by applying various techniques to the source code, which in turn preserves the behavior of code. Refactoring facilitates bug removal and extends the capabilities of the program. In this paper, an exhaustive review is conducted regarding bad smells present in source code, applications of specific refactoring methods to remove that bad smell and its effect on software quality. A total of 68 studies belonging to 32 journals, 31 conferences, and 5 other sources that were published between the years 2001 and 2019 were shortlisted. The studies were analyzed based on of bad smells identified, refactoring techniques used, and their effects on software metrics. We found that "long method", "feature envy", and "data class" bad smells were identified or corrected in the majority of studies. "Feature envy" smell was detected in 36.66% of the total shortlisted studies. Extract class refactoring approach was used in 38.77% of the total studies, followed by the move method and extract method techniques that were used in 34.69% and 30.61% of the total studies, respectively. The effects of refactoring on complexity and coupling metrics of software were also analyzed in the majority of studies, i.e., 29 studies each. Interestingly, the majority of selected studies (41%) used large open source datasets written in Java language instead of proprietary software. At the end, this study provides future guidelines for conducting research in the field of code refactoring.

Keywords

References

  1. F. A. Fontana, M. Mangiacavalli, D. Pochiero, and M. Zanoni, "On experimenting refactoring tools to remove code smells," in Scientific Workshop Proceedings of the XP2015, Helsinki, Finland, 2015, pp.1-8.
  2. F. A. Fontana, P. Braione, and M. Zanoni, "Automatic detection of bad smells in code: an experimental assessment," Journal of Object Technology, vol. 11, no. 2, article no. 5, 2012.
  3. M. Fowler, Refactoring: Improving the Design of Existing Code. Boston, MA: Addison-Wesley; 2019.
  4. R. Malhotra and A. Chug, "An empirical study to assess the effects of refactoring on software maintainability," in Proceedings of 2016 International Conference on Advances in Computing, Communications and Informatics (ICACCI), Jaipur, India, 2016, pp. 110-117.
  5. T. Mens and T. Tourwe, "A survey of software refactoring," IEEE Transactions on Software Engineering, vol. 30, no. 2, pp. 126-139, 2004. https://doi.org/10.1109/TSE.2004.1265817
  6. M. Zhang, T. Hall, and N. Baddoo, "Code bad smells: a review of current knowledge," Journal of Software Maintenance and Evolution: Research and Practice, vol. 23, no. 3, pp. 179-202, 2011. https://doi.org/10.1002/smr.521
  7. M. Xenos, D. Stavrinoudis, K. Zikouli, and D. Christodoulakis, "Object-oriented metrics-a survey," in Proceedings of the Federation of European Software Measurement Associations (FESMA), Madrid Madrid, Spain, 2000, pp. 1-10.
  8. M. Alshayeb, "Empirical investigation of refactoring effect on software quality," Information and Software Technology, vol. 51, no. 9, pp. 1319-1326, 2009. https://doi.org/10.1016/j.infsof.2009.04.002
  9. M. J. Munro, "Product metrics for automatic identification of "Bad smell" design problems in Java sourcecode," in Proceedings of 11th IEEE International Software Metrics Symposium (METRICS'05), Como, Italy, 2005, pp. 15.
  10. I. Kadar, P. Hegedus, R. Ferenc, and T. Gyimothy, "A code refactoring dataset and its assessment regarding software maintainability," in Proceedings of 2016 IEEE 23rd International Conference on Software Analysis, Evolution, and Reengineering (SANER), Suita, Japan, 2016, pp. 599-603.
  11. Y. Kataoka, T. Imai, H. Andou, and T. Fukaya, "A quantitative evaluation of maintainability enhancement by refactoring," in Proceedings of International Conference on Software Maintenance, Montreal, Canada, 2002, pp. 576-585.
  12. M. Zhang, N. Baddoo, P. Wernick, and T. Hall, "Prioritising refactoring using code bad smells," in Proceedings of 2011 IEEE 4th International Conference on Software Testing, Verification and Validation Workshops, Berlin, Germany, 2011, pp. 458-464.
  13. S. Singh and K. S. Kahlon, "Effectiveness of encapsulation and object-oriented metrics to refactor code and identify error prone classes using bad smells," ACM SIGSOFT Software Engineering Notes, vol. 36, no. 5, pp. 1-10, 2011.
  14. W. Li and R. Shatnawi, "An empirical study of the bad smells and class error probability in the post-release object-oriented system evolution," Journal of Systems and Software, vol. 80, no. 7, pp. 1120-1128, 2007. https://doi.org/10.1016/j.jss.2006.10.018
  15. B. Du Bois, S. Demeyer, and J. Verelst, "Refactoring - improving coupling and cohesion of existing code," in Proceedings of the 11th Working Conference on Reverse Engineering, Delft, Netherlands, 2004, pp. 144-151.
  16. M. Hammad and A. Labadi, "Automatic detection of bad smells from code changes," International Review on Computers and Software, vol. 11, no. 11, pp. 1016-1027, 2016.
  17. E. H. Vashisht, S. Bharadwaj, and S. Sharma, "Impact of Clone Refactoring on External Quality Attributes of Open Source Softwares," International Journal of Scientific Research in Computer Science, Engineering, and Information Technology, vol. 3, no. 8, pp. 86-94, 2018.
  18. F. Khomh, M. Di Penta, and Y. Gueheneuc, "An exploratory study of the impact of code smells on software change-proneness," in Proceedings of 2009 16th Working Conference on Reverse Engineering, Lille, France, 2009, pp. 75-84.
  19. N. Tsantalis, T. Chaikalis, and A. Chatzigeorgiou, "JDeodorant: identification and removal of type-checking bad smells," in Proceedings of 2008 12th European Conference on Software Maintenance and Reengineering, Athens, Greece, 2008, pp. 329-331.
  20. M. Alshayeb, "Refactoring effect on cohesion metrics," in Proceedings of 2009 International Conference on Computing, Engineering and Information, Fullerton, CA, 2009, pp. 3-7.
  21. JJ. Ratzinger, M. Fischer, and H. Gall, "Improving evolvability through refactoring," in Proceedings of the 2005 International Workshop on Mining Software Repositories, St. Louis, MO, 2005, pp. 1-5.
  22. M. Fokaefs, N. Tsantalis, and A. Chatzigeorgiou, "JDeodorant: identification and removal of feature envy bad smells," in Proceedings of 2007 IEEE International Conference on Software Maintenance, Paris, France, 2007, pp. 519-520.
  23. O. Chaparro, G. Bavota, A. Marcus, and M. D. Penta, "On the impact of refactoring operations on code quality metrics," in Proceedings of 2014 IEEE International Conference on Software Maintenance and Evolution, Victoria, BC, Canada, 2014, pp. 456-460.
  24. P. Meananeatra, "Identifying refactoring sequences for improving software maintainability," in Proceedings of the 27th IEEE/ACM International Conference on Automated Software Engineering, Essen, Germany, 2012, pp. 406-409.
  25. F. Palomba, G. Bavota, M. Di Penta, R. Oliveto, A. De Lucia, and D. Poshyvanyk, "Detecting bad smells in source code using change history information," in Proceedings of 2013 28th IEEE/ACM International Conference on Automated Software Engineering (ASE), Silicon Valley, CA, 2013, pp. 268-278.
  26. P. Danphitsanuphan and T. Suwantada, "Code smell detecting tool and code smell-structure bug relationship," in Proceedings of 2012 Spring Congress on Engineering and Technology, Xian, China, 2012, pp. 1-5.
  27. R. Oliveto, M. Gethers, G. Bavota, D. Poshyvanyk, and A. De Lucia, "Identifying method friendships to remove the feature envy bad smell: NIER track," in Proceedings of 2011 33rd International Conference on Software Engineering (ICSE), Honolulu, HI, 2011, pp. 820-823.
  28. Y. Kataoka, M. D. Ernst, W. G. Griswold, and D. Notkin, "Automated support for program refactoring using invariants," in Proceedings IEEE International Conference on Software Maintenance (ICSM), Florence, Italy, 2001, pp. 736-743.
  29. K. Stroggylos and D. Spinellis, "Refactoring: does it improve software quality?," in Proceedings of 5th International Workshop on Software Quality (WoSQ, Minneapolis, MN, 2007, p. 10.
  30. M. O Cinneide, L. Tratt, M. Harman, S. Counsell, and I. H. Moghadam, "Experimental assessment of software metrics using automated refactoring," in Proceedings of the ACM-IEEE International Symposium on Empirical Software Engineering and Measurement, Lund, Sweden, 2012, pp. 49-58.
  31. C. Napoli, G. Pappalardo, and E. Tramontana, "Using modularity metrics to assist move method refactoring of large systems," in Proceedings of 2013 Seventh International Conference on Complex, Intelligent, and Software Intensive Systems, Taichung, Taiwan, 2013, pp. 529-534.
  32. M. O'Keeffe and M. O. Cinneide, "Search-based refactoring: an empirical study," Journal of Software Maintenance and Evolution: Research and Practice, vol. 20, no. 5, pp. 345-364, 2008. https://doi.org/10.1002/smr.378
  33. P. Hegedus, I. Kadar, R. Ferenc, and T. Gyimothy, "Empirical evaluation of software maintainability based on a manually validated refactoring dataset," Information and Software Technology, vol. 95, pp. 313-327, 2018. https://doi.org/10.1016/j.infsof.2017.11.012
  34. M. O'Keeffe and M. O. Cinneide, "Search-based refactoring for software maintenance," Journal of Systems and Software, vol. 81, no. 4, pp. 502-516, 2008. https://doi.org/10.1016/j.jss.2007.06.003
  35. J. Dexun, M. Peijun, S. Xiaohong, and W. Tiantian, "Detection and refactoring of bad smell caused by large scale," International Journal of Software Engineering & Applications, vol. 4, no. 5, pp. 1-13, 2013. https://doi.org/10.5121/ijsea.2013.4501
  36. A. Hamid, M. Ilyas, M. Hummayun, and A. Nawaz, "A Comparative study on code smell detection tools," International Journal of Advanced Science and Technology, vol. 60, pp. 25-32, 2013. https://doi.org/10.14257/ijast.2013.60.03
  37. A. Chug and M. Gupta, "A quality enhancement through defect reduction using refactoring operation," in Proceedings of 2017 International Conference on Advances in Computing, Communications and Informatics (ICACCI), Udupi, India, 2017, pp. 1869-1875.
  38. Y. Khrishe and M. Alshayeb, "An empirical study on the effect of the order of applying software refactoring," in Proceedings of 2016 7th International Conference on Computer Science and Information Technology (CSIT), Amman, Jordan, 2016, pp. 1-4.
  39. J. Park, B. Jeon, R. Y. C. Kim, and H. S. Son, "Improving source code against bad-smell code patterns," Journal of Engineering Technology, vol. 6, no. 2, pp. 503-516, 2018.
  40. N. Tsantalis and A. Chatzigeorgiou, "Identification of refactoring opportunities introducing polymorphism," Journal of Systems and Software, vol. 83, no. 3, pp. 391-404, 2010. https://doi.org/10.1016/j.jss.2009.09.017
  41. S. M. Olbrich, D. S. Cruzes, and D. I. K. Sjoberg, "Are all code smells harmful? A study of God Classes and Brain Classes in the evolution of three open source systems," in Proceedings of 2010 IEEE International Conference on Software Maintenance, Timisoara, Romania, 2010, pp. 1-10.
  42. C. Vassallo, G. Grano, F. Palomba, H. C. Gall, and A. Bacchelli, "A large-scale empirical exploration on refactoring activities in open source software projects," Science of Computer Programming, vol. 180, pp. 1-15, 2019. https://doi.org/10.1016/j.scico.2019.05.002
  43. F. Palomba, A. Panichella, A. De Lucia, R. Oliveto, and A. Zaidman, "A textual-based technique for Smell Detection," in Proceedings of 2016 IEEE 24th International Conference on Program Comprehension (ICPC), Austin, TX, 2016, pp. 1-10.
  44. D. Jiang, P. Ma, X. Su, and T. Wang, "Distance metric based divergent change bad smell detection and refactoring scheme analysis," International Journal of Innovative Computing, Information and Control, vol. 10, no. 4, pp. 1519-1531, 2014.
  45. A. Rani and H. Kaur, "Detection of bad smells in source code according to their object oriented metrics," International Journal for Technological Research in Engineering, vol. 1, no. 10, pp. 1211-1214, 2014.
  46. Y. Kosker, B. Turhan, and A. Bener, "An expert system for determining candidate software classes for refactoring," Expert Systems with Applications, vol. 36, no. 6, pp. 10000-10003, 2009. https://doi.org/10.1016/j.eswa.2008.12.066
  47. N. Yoshida, T. Saika, E. Choi, A. Ouni, and K. Inoue, "Revisiting the relationship between code smells and refactoring," in Proceedings of 2016 IEEE 24th International Conference on Program Comprehension (ICPC), Austin, TX, 2016, pp. 1-4.
  48. A. Ouni, M. Kessentini, and H. Sahraoui, "Search-based refactoring using recorded code changes," in Proceedings of 2013 17th European Conference on Software Maintenance and Reengineering, Genova, Italy, 2013, pp. 221-230.
  49. J. Al Dallal, "Constructing models for predicting extract subclass refactoring opportunities using objectoriented quality metrics," Information and Software Technology, vol. 54, no. 10, pp. 1125-1141, 2012. https://doi.org/10.1016/j.infsof.2012.04.004
  50. G. Bavota, A. De Lucia, M. Di Penta, R. Oliveto, and F. Palomba, "An experimental investigation on the innate relationship between quality and refactoring," Journal of Systems and Software, vol. 107, pp. 1-14, 2015. https://doi.org/10.1016/j.jss.2015.05.024
  51. S. Tarwani and A. Chug, "Sequencing of refactoring techniques by Greedy algorithm for maximizing maintainability," in Proceedings of 2016 International Conference on Advances in Computing, Communications and Informatics (ICACCI), Jaipur, India, 2016, pp. 1397-1403.
  52. R. Malhotra, A. Chug, and P. Khosla, "Prioritization of classes for refactoring: a step towards improvement in software quality," in Proceedings of the Third International Symposium on Women in Computing and Informatics, Kochi, India, 2015, pp. 228-234.
  53. A. Chug and S. Tarwani, "Determination of optimum refactoring sequence using A∗ algorithm after prioritization of classes," in Proceedings of 2017 International Conference on Advances in Computing, Communications and Informatics (ICACCI), Udupi, India, 2017, pp. 1624-1630.
  54. H. Mumtaz, M. Alshayeb, S. Mahmood, and M. Niazi, "An empirical study to improve software security through the application of code refactoring," Information and Software Technology, vol. 96, pp. 112-125, 2018. https://doi.org/10.1016/j.infsof.2017.11.010
  55. R. Ibrahim, M. Ahmed, R. Nayak, and S. Jamel, "Reducing redundancy of test cases generation using code smell detection and refactoring," Journal of King Saud University - Computer and Information Sciences, vol. 32, no. 3, pp. 367-374, 2020. https://doi.org/10.1016/j.jksuci.2018.06.005
  56. A. Blouin, V. Lelli, B. Baudry, and F. Coulon, "User interface design smell: automatic detection and refactoring of Blob listeners," Information and Software Technology, vol. 102, pp. 49-64, 2018. https://doi.org/10.1016/j.infsof.2018.05.005
  57. M. Tufano, F. Palomba, G. Bavota, R. Oliveto, M. Di Penta, A. De Lucia, and D. Poshyvanyk, "When and why your code starts to smell bad," in Proceedings of 2015 IEEE/ACM 37th IEEE International Conference on Software Engineering, Florence, Italy, 2015, pp. 403-414.
  58. S. Charalampidou, A. Ampatzoglou, and P. Avgeriou, "Size and cohesion metrics as indicators of the long method bad smell," in Proceedings of the 11th International Conference on Predictive Models and Data Analytics in Software Engineering, Beijing, China, 2015, pp. 1-10.
  59. M. A. S. Bigonha, K. Ferreira, P. Souza, B. Sousa, M. Januario, and D. Lima, "The usefulness of software metric thresholds for detection of bad smells and fault prediction," Information and Software Technology, vol. 115, pp. 79-92, 2019. https://doi.org/10.1016/j.infsof.2019.08.005
  60. D. Cedrim, A. Garcia, M. Mongiovi, R. Gheyi, L. Sousa, R. de Mello, B. Fonseca, M. Ribeiro, and A. Chavez, "Understanding the impact of refactoring on smells: a longitudinal study of 23 software projects," in Proceedings of the 2017 11th Joint Meeting on Foundations of Software Engineering, Paderborn, Germany, 2017, pp. 465-475.
  61. L. Kumar, S. M. Satapathy, and L. B. Murthy, "Method level refactoring prediction on five open source Java Projects using machine learning techniques," in Proceedings of the 12th Innovations on Software Engineering Conference (formerly known as India Software Engineering Conference), Pune, India, 2019, pp. 1-10.
  62. A. Chug and S. Gupta, "Enhancing the life of legacy software through refactoring based systematic transformation," in Proceedings of the 10th International Multi-Conference on Complexity, Informatics and Cybernetics (IMCIC 2019), Orlando, FL, 2019, pp. 216-221.
  63. S. Kebir, I. Borne, and D. Meslati, "A genetic algorithm-based approach for automated refactoring of component-based software," Information and Software Technology, vol. 88, pp. 17-36, 2017. https://doi.org/10.1016/j.infsof.2017.03.009
  64. G. Rasool and Z. Arshad, "A Lightweight approach for detection of code smells," Arabian Journal for Science and Engineering, vol. 42, no. 2, pp. 483-506, 2016.
  65. M. W. Mkaouer, M. Kessentini, M. O. Cinneide, S. Hayashi, and K. Deb, "A robust multi-objective approach to balance severity and importance of refactoring opportunities," Empirical Software Engineering, vol. 22, no. 2, pp. 894-927, 2016.
  66. S. A. Vidal, C. Marcos, and J. A. Diaz-Pace, "An approach to prioritize code smells for refactoring," Automated Software Engineering, vol. 23, no. 3, pp. 501-532, 2014.
  67. R. Terra, M. T. Valente, S. Miranda, and V. Sales, "JMove: a novel heuristic and tool to detect move method refactoring opportunities," Journal of Systems and Software, vol. 138, pp. 19-36, 2018. https://doi.org/10.1016/j.jss.2017.11.073
  68. F. Arcelli Fontana and M. Zanoni, "Code smell severity classification using machine learning techniques," Knowledge-Based Systems, vol. 128, pp. 43-58, 2017. https://doi.org/10.1016/j.knosys.2017.04.014
  69. F. Arcelli Fontana, M. V. Mantyla, M. Zanoni, and A. Marino, "Comparing and experimenting machine learning techniques for code smell detection," Empirical Software Engineering, vol. 21, no. 3, pp. 1143-1191, 2015.
  70. J. Dexun, M. Peijun, S. Xiaohong, and W. Tiantian, "Functional over-related classes bad smell detection and refactoring suggestions," International Journal of Software Engineering & Applications, vol. 5, no. 2, pp. 29-47, 2014. https://doi.org/10.5121/ijsea.2014.5203
  71. A. Ouni, M. Kessentini, H. Sahraoui, K. Inoue, and M. S. Hamdi, "Improving multi-objective code-smells correction using development history," Journal of Systems and Software, vol. 105, pp. 18-39, 2015. https://doi.org/10.1016/j.jss.2015.03.040
  72. U. Mansoor, M. Kessentini, M. Wimmer, and K. Deb, "Multi-view refactoring of class and activity diagrams using a multi-objective evolutionary algorithm," Software Quality Journal, vol. 25, no. 2, pp. 473-501, 2015.
  73. A. Ouni, M. Kessentini, S. Bechikh, and H. Sahraoui, "Prioritizing code-smells correction tasks using chemical reaction optimization," Software Quality Journal, vol. 23, no. 2, pp. 323-361, 2014. https://doi.org/10.1007/s11219-014-9233-7