Advertisement

Software Quality Journal

, Volume 23, Issue 2, pp 323–361 | Cite as

Prioritizing code-smells correction tasks using chemical reaction optimization

  • Ali Ouni
  • Marouane Kessentini
  • Slim Bechikh
  • Houari Sahraoui
Article

Abstract

The presence of code-smells increases significantly the cost of maintenance of systems and makes them difficult to change and evolve. To remove code-smells, refactoring operations are used to improve the design of a system by changing its internal structure without altering the external behavior. In large-scale systems, the number of code-smells to fix can be very large and not all of them can be fixed automatically. Thus, the prioritization of the list of code-smells is required based on different criteria such as the risk and importance of classes. However, most of the existing refactoring approaches treat the code-smells to fix with the same importance. In this paper, we propose an approach based on a chemical reaction optimization metaheuristic search to find the suitable refactoring solutions (i.e., sequence of refactoring operations) that maximize the number of fixed riskiest code-smells according to the maintainer’s preferences/criteria. We evaluate our approach on five medium- and large-sized open-source systems and seven types of code-smells. Our experimental results show the effectiveness of our approach compared to other existing approaches and three different others metaheuristic searches.

Keywords

Search-based software engineering Refactoring, software quality Code-smells Chemical reaction optimization 

References

  1. Alba, E., & Chicano, F. (2005). Management of software projects with GAs. In Proceedings of the 6th metaheuristics international conference (MIC’05). Elsevier, 13–18, 2005.Google Scholar
  2. Alikacem, H., & Sahraoui. H. (2006). Détection d’anomalies utilisant un langage de description de règle de qualité, in actes du 12e colloque LMO.Google Scholar
  3. Arcuri, A., & Briand, L. C. (2011). A practical guide for using statistical tests to assess randomized algorithms in software engineering. In Proceedings of the 33rd international conference on software engineering (ICSE ‘11), (pp. 1–10). New York, NY, USA: ACM.Google Scholar
  4. Brown, W. J., Malveau, R. C., Brown, W. H., McCornnick, W. H, I. I. I., & Mowbray, T. J. (1998). Anti patterns: Refactoring software, architectures, and projects in crisis. New York: Wiley.Google Scholar
  5. Canfora, G., Di Penta, M., Esposito, R., & Andvillani, M. L. (2005) An approach for QoS-aware service composition based on genetic algorithms. In Proceedings of the conference on genetic and evolutionary computation (GECCO’05), (pp. 1069–1075). New York: ACM Press.Google Scholar
  6. Cederqvist, P. (2003). Version management with CVS, December 2003. www.cvshome.org/docs/manual/.
  7. Chidamber, S. R., & Kemerer, C. F. (1994). A metrics suite for object oriented design. IEEE Transactions on Software Engineering, 20(6), 476–493.CrossRefGoogle Scholar
  8. Cinnéide, M. Ó., Tratt, L., Harman, M., Counsell, S., & Moghadam, I. H. (2012). Experimental assessment of software metrics using automated refactoring. In Proceedings of empirical software engineering and management (ESEM), pp. 49–58, September 2012.Google Scholar
  9. Cohen, J. (1988). Statistical power analysis for the behavioral sciences (2nd ed.). New York, USA: Lawrence Earlbaum Associates.Google Scholar
  10. Du Bois, B., Demeyer, S., & Verelst, J. (2004). Refactoring—Improving coupling and cohesion of existing code. In Proceedings of 11th working conference reverse engineering (WCRE), 2004, pp. 144–151.Google Scholar
  11. Erlikh, L. (2000). Leveraging legacy system dollars for e-business. IT Professional, 02(3), 17–23.CrossRefGoogle Scholar
  12. Fatiregun, D., Harman, M., & Hierons, R. (2004). Evolving transformation sequences using genetic algorithms. In SCAM 04, (pp. 65–74). Los Alamitos, CA, USA: IEEE Computer Society Press.Google Scholar
  13. Fenton, N., & Pfleeger, S. L. (1997). Software metrics: A rigorous and practical approach (2nd ed.). London: International Thomson Computer Press.Google Scholar
  14. Fowler, M., Beck, K., Brant, J., Opdyke, W., & Roberts, D. (1999). Refactoring: Improving the design of existing code (1st ed.). Reading, MA: Addison-Wesley.Google Scholar
  15. Freitas, F. G., & Souza, J. T. (2011). Ten years of search based software engineering: A bibliometric analysis. In 3rd international symposium on search based software engineering (SSBSE 2011), 10–12th September 2011, pp. 18–32.Google Scholar
  16. Fraser, G., & Arcuri, A. (2013). Handling test length bloat. Software Testing, Verification and Reliability, 23(7), 553–582.CrossRefGoogle Scholar
  17. Glover, F., & Laguna, M. (1997). Tabu search. Boston, MA: Kluwer Academic Publishers.CrossRefzbMATHGoogle Scholar
  18. Goldberg, D. E. (1989). Genetic algorithms in search, optimization, and machine learning. Reading, MA: Addison-Wesley.zbMATHGoogle Scholar
  19. GanttProject. [Online].Google Scholar
  20. Harman, M. (2007). The current state and future of search based software engineering. In L. Briand & A. Wolf (Eds.), Future of software engineering 2007 (pp. 342–357). Los Alamitos, CA: IEEE Computer Society Press.Google Scholar
  21. Harman, M., & Jones, B. F. (2001). Search-based software engineering. Information and Software Technology, 43(14), 833–839.CrossRefGoogle Scholar
  22. Harman, M., & Tratt, L. (2007) Pareto optimal search based refactoring at the design level. In Proceedings of the genetic and evolutionary computation conference (GECCO’07), 2007, pp. 1106–1113.Google Scholar
  23. Harman, M., Mansouri, S. A., & Zhang, Y. (2012). Search-based software engineering: Trends, techniques and applications. ACM Computing Surveys, 45, 61.CrossRefGoogle Scholar
  24. Infusion hydrogen: Design flaw detection tool. 2012.Google Scholar
  25. Jensen, A., & Cheng, B. (2010). On the use of genetic programming for automated refactoring and the introduction of design patterns. In Proceedings of GECCO. ACM, July 2010.Google Scholar
  26. Joshi, P., & Joshi, R. K. (2009). Concept analysis for class cohesion. In Proceedings of the 13th European conference on software maintenance and reengineering, Kaiserslautern, Germany, pp. 237–240, 2009.Google Scholar
  27. JFreeChart. [Online].Google Scholar
  28. JHotDraw. [Online].Google Scholar
  29. Jourdan, L., Basseur, M., & Talbi, E.-G. (2009). Hybridizing exact methods and metaheuristics: A taxonomy. European Journal of Operational Research, 199(3), 620–629.CrossRefzbMATHMathSciNetGoogle Scholar
  30. Kataoka, Y., Ernst, M. D., Griswold, W. G., & Notkin, D. (2001). Automated support for program refactoring using invariants. In International conference on software maintenance (ICSM), pp. 736–743, 2001.Google Scholar
  31. Kennedy, J., & Eberhart, R. C. (1995). Particle swarm optimization. In Proceedings of IEEE international conference neural networks, Perth, Australia, November 1995, pp. 1942–1948.Google Scholar
  32. Kessentini, M., Vaucher, S., & Sahraoui, H. (2010). Deviance from perfection is a better criterion than closeness to evil when identifying risky code. In Proceedings of the international conference on automated software engineering, ASE’10, 2010.Google Scholar
  33. Kessentini, M., Kessentini, W., Sahraoui, H., Boukadoum, M., & Ouni, A. (2011) Design defects detection and correction by example. In 19th IEEE ICPC11, Kingston, Canada, pp. 81–90.Google Scholar
  34. Khomh, F., Penta, M. D., & Gueheneuc, Y.-G. (2009a). An exploratory study of the impact of code smells on software change-proneness. In Proceedings of WCRE 2009 (16th IEEE working conference on reverse engineering), pp. 75–84, 2009.Google Scholar
  35. Khomh, F., Vaucher, S., Guéhéneuc, Y.-G., & Sahraoui, H. (2009b). A bayesian approach for the detection of code and design smells. In Proceedings of the ICQS’09.Google Scholar
  36. Kilic, H., Koc, E., & Cereci, I. (2011). Search-based parallel refactoring using population-based direct approaches. In Proceedings of the third international conference on search based software engineering, SSBSE’11, pp. 271–272, 2011.Google Scholar
  37. Kirkpatrick, S., Gelatt, C. D, Jr, & Vecchi, M. P. (1983). Optimization by simulated annealing. Science, 220(4598), 671–680.CrossRefzbMATHMathSciNetGoogle Scholar
  38. Lam, A. Y. S., & Li, V. O. K. (2010). Chemical-reaction-inspired metaheuristic for optimization. IEEE Transactions Evolutionary Computation, 14(3), 381–399.CrossRefGoogle Scholar
  39. Lam, A. Y. S., Li, V. O. -K., & Wei, Z. (2012a). Chemical reaction optimization for the fuzzy rule learning problem. Evolutionary Computation (CEC), 2012 IEEE Congress on 10–15 June 2012, pp. 1–8.Google Scholar
  40. Lam, A. Y. S., Li, V. O. K., & Yu, J. J. Q. (2012b). Real-coded chemical reaction optimization. IEEE Transactions Evolutionary Computation, 16(3), 339–353.CrossRefGoogle Scholar
  41. Lam, A. Y. S., Li, V. O. K., & Xu, J. (2013). On the convergence of chemical reaction optimization for combinatorial optimization. IEEE Transaction Evolutionary Computation, 17(5), 605–620.CrossRefGoogle Scholar
  42. Le Goues, C., Nguyen, T., Forrest, S., & Weimer, W. (2012). Genprog: A generic method for automatic software repair. IEEE Transactions on Software Engineering, 38(1), 54–72.CrossRefGoogle Scholar
  43. Marinescu, R. (2004). Detection strategies: Metrics-based rules for detecting design flaws. In Proceedings of the 20th international conference on software maintenance (pp. 350–359). IEEE Computer Society Press.Google Scholar
  44. Martin, R. C. (2008). Clean code: A handbook of agile software craftsmanship. Englewood Cliffs: Prentice Hall.Google Scholar
  45. McMinn, P. (2004). Search-Based software test data generation: A survey. Software Testing, Verification and Reliability, 14, 2.CrossRefGoogle Scholar
  46. Mens, T., & Tourwé, T. (2004). A survey of software refactoring. IEEE Transactions on Software Engineering, 30(2), 126–139.CrossRefGoogle Scholar
  47. Moha, N., Hacene, A., Valtchev, P. & Guéhéneuc, Y.-G. (2008). Refactorings of design defects using relational concept analysis. In R. Medina, & S. Obiedkov (Eds.), Proceedings of the 4th international conference on formal concept analysis (ICFCA 2008), February 2008.Google Scholar
  48. Moha, N., Guéhéneuc, Y.-G., Duchien, L., & Meur, A.-F. L. (2010). DECOR: A method for the specification and detection of code and design smells. Transactions on Software Engineering (TSE) 36(1), 20–36.Google Scholar
  49. Munro, M. J. (2005). Product metrics for automatic identification of bad smell” design problems in java source-code. In F. Lanubile, & C. Seaman (Eds.), Proceedings of the 11th international software metrics symposium. IEEE Computer Society Press (2005).Google Scholar
  50. Ó Cinnéide, M. (2000). Automated application of design patterns: A refactoring approach. Ph.D. dissertation, University of Dublin, Trinity College, Department of Computer Science, 2000.Google Scholar
  51. O’Keeffe, M., & Cinnéide, M. O. (2006). Search-based refactoring for software maintenance. Journal of Systems and Software, 81(4), 502–516.CrossRefGoogle Scholar
  52. Olbrich, S., Cruzes, D., Basili, V. R., & Zazworka, N. (2009) The evolution and impact of code smells: A case study of two open source systems. In ESEM, pp. 390–400.Google Scholar
  53. Olbrich, S. M., Cruzes, D. S., & Sjoberg, D. I. K. (2010). Are all code smells harmful? A study of god classes and brain classes in the evolution of three open source systems. In Software maintenance, ICSM 2010, pp. 1–10, Timisoara, 2010.Google Scholar
  54. Opdyke, W. F. (1992). Refactoring: A program restructuring aid in designing object-oriented application frameworks. Ph.D. thesis, University of Illinois at Urbana-Champaign, 1992.Google Scholar
  55. Otero, F. E. B., Johnson, C. G., Freitas, A. A., & Thompson., S. J. (2010) Refactoring in automatically generated programs. In Search based software engineering, international symposium on, 0, 2010.Google Scholar
  56. Ouni, A., Kessentini, M., Sahraoui, H., & Boukadoum, M. (2012a). Maintainability defects detection and correction: A multi-objective approach. Journal of Automated Software Engineering, 20(1), 47–79.Google Scholar
  57. Ouni, A., Kessentini, M., Sahraoui, H., & Hamdi, M. S. (2012b) Search-based refactoring: Towards semantics preservation. In 28th IEEE international conference on software maintenance (ICSM), (pp. 347–356), September 23–28, 2012.Google Scholar
  58. Ouni, A., Kessentini, M., & Sahraoui, H. (2013). Search-based refactoring using recorded code changes. In Proceedings of the 17th European conference on software maintenance and reengineering (CSMR), Genova, Italy, March 5–8, 2013.Google Scholar
  59. Prete, K., Rachatasumrit, N., Sudan, N., & M. Kim. (2010) Template-based reconstruction of complex refactorings. In Proceedings of the international conference on software maintenance (ICSM), 2010.Google Scholar
  60. Qayum, F., & Heckel, R. (2009) Local search-based refactoring as graph transformation. In Proceedings of 1st international symposium on search based software engineering, pp. 43–46, 2009.Google Scholar
  61. Ratiu, D., Ducasse, S., Gîrba, T., & Marinescu, R. (2004) Using history information to improve design flaws detection. In CSMR, pp. 223–232.Google Scholar
  62. Riel, A. J. (1996). Object-oriented design heuristics. Reading, MA: Addison-Wesley.Google Scholar
  63. Roberts, D. B. (1999). Practical analysis for refactoring. PhD thesis, Department of Computer Science, University of Illinois, 1999.Google Scholar
  64. Sahraoui, H., Godin, R., & Miceli, T. (2000). Can metrics help to bridge the gap between the Improvement of OO design quality and its automation? ICSM, 2000, 154–162.Google Scholar
  65. Seng, O., Stammel, J., & Burkhart, D. (2006). Search-based determination of refactorings for improving the class structure of object-oriented systems. In Proceedings of the genetic and evolutionary computation conference (GECCO’06), 2006, pp. 1909–1916.Google Scholar
  66. Sun, Y., Lam, A. Y. S., Li, V. O. -K., Xu, J., & Yu, J. J. Q. (2012). Chemical reaction optimization for the optimal power flow problem. Evolutionary Computation (CEC), 2012 IEEE Congress on 10–15 June 2012, pp. 1–8.Google Scholar
  67. Tahvildari, L., & Kontogiannis, K. (2003). A metric-based approach to enhance design quality through meta-pattern transformation. In Proceedings of the 7th European conference on software maintenance and reengineering, Benevento, Italy, pp. 183–192, 2003.Google Scholar
  68. Tsantalis, N., Chaikalis, T., & Chatzigeorgiou, A. (2008). JDeodorant: Identification and removal of type-checking bad smells. In Proceedings of CSMR2008, pp 329–331.Google Scholar
  69. Vallée-Rai, R., Gagnon, E., Hendren, L. J., Lam, P., Pominville, P., & Sundaresan, V. (2000). Optimizing Java bytecode using the Soot framework: Is it feasible? In International conference on compiler construction, pp. 18–34, 2000.Google Scholar
  70. Xu, J., Lam, A. Y. S., & Li, V. O. K. (2011). Chemical reaction optimization for task scheduling in grid computing. IEEE Transactions on Parallel and Distributed Systems, 22(10), 1624–1631.CrossRefGoogle Scholar
  71. Xerces-J. [Online].Google Scholar
  72. Yu, J. J. Q., Lam, A. Y. S., & Li, V. O. -. (2012) Real-coded chemical reaction optimization with different perturbation functions. Evolutionary Computation (CEC), 2012 IEEE Congress on 10–15 June 2012, pp. 1–8.Google Scholar
  73. Zhang, Y., Finkelstein, A., & Andharman, M. (2008). Search based requirements optimisation: Existing work and challenges. In Proceedings of the 14th international working conference, requirements engineering: Foundation for software quality (RefsQ’08). Lecture notes in computer science, (Vol. 5025, pp. 88–94). New York: Springer.Google Scholar

Copyright information

© Springer Science+Business Media New York 2014

Authors and Affiliations

  • Ali Ouni
    • 1
    • 2
  • Marouane Kessentini
    • 2
  • Slim Bechikh
    • 2
  • Houari Sahraoui
    • 1
  1. 1.DIRO, GEODES LabUniversity of MontrealMontrealCanada
  2. 2.CIS, SBSE-Michigan LabUniversity of MichiganMichiganUSA

Personalised recommendations