Search-Based Refactoring Detection Using Software Metrics Variation

  • Rim Mahouachi
  • Marouane Kessentini
  • Mel Ó Cinnéide
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 8084)


Software is frequently refactored to improve its design, either as part of an agile development process or as part of a major design overhaul. In either case, it is very useful to determine what refactorings have recently taken place in order to comprehend better the software and its development trajectory. To this end, we have developed an approach to automate the detection of source code refactorings using structural information extracted from the source code. Our approach takes as input a list of possible refactorings, a set of structural metrics and the initial and revised versions of the source code. It generates as output a sequence of detected changes expressed as refactorings. This refactoring sequence is determined by a search-based process that minimizes the metrics variation between the revised version of the software and the version yielded by the application of the refactoring sequence to the initial version of the software. We use both global and local heuristic search algorithms to explore the space of possible solutions. In applying our approach to several versions of four open source projects we find the average Precision and Recall to be over 90%, thus confirming the effectiveness of our detection approach.


Search-based software engineering refactoring software metrics 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Robbes, R.: Mining a Change-Based Software Repository. In: Proceedings of MSR 2007, pp. 15–23. IEEE Computer Society (2007)Google Scholar
  2. 2.
    Dig, D., Comertoglu, C., Marinov, D., Johnson, R.: Automated Detection of Refactorings in Evolving Components. In: Thomas, D. (ed.) ECOOP 2006. LNCS, vol. 4067, pp. 404–428. Springer, Heidelberg (2006)Google Scholar
  3. 3.
    Weissgerber, P., Diehl, S.: Identifying Refactorings from Source-Code Changes. In: Proceedings of ASE 2006, pp. 231–240. IEEE (2006)Google Scholar
  4. 4.
    Kim, M., Notkin, D., Grossman, D., Wilson Jr., G.: Identifying and Summarizing Systematic Code Changes via Rule Inference. TSE: IEEE Transactions on Software Engineering, 45–62 (2013)Google Scholar
  5. 5.
    Prete, K., Rachatasumrit, N., Sudan, N., Kim, M.: Template-based reconstruction of complex refactorings. In: ICSM 2010, pp. 1–10 (2010)Google Scholar
  6. 6.
    Fowler, M., Beck, K., Brant, J., Opdyke, W., Roberts, D.: Refactoring – Improving the Design of Existing Code, 1st edn. Addison-Wesley (June 1999)Google Scholar
  7. 7.
    Liu, H., Yang, L., Niu, Z., Ma, Z., Shao, W.: Facilitating software refactoring with appropriate resolution order of bad smells. In: Proc. of the ESEC/FSE 2009, pp. 265–268 (2009)Google Scholar
  8. 8.
    Harman, M., Tratt, L.: Pareto optimal search based refactoring at the design level. In: Proceedings of the Genetic and Evolutionary Computation Conference (GECCO 2007), pp. 1106–1113 (2007)Google Scholar
  9. 9.
    Seng, O., Stammel, J., Burkhart, D.: Search-based determination of refactorings for improving the class structure of object-oriented systems. In: GECCO 2006, pp. 1909–1916 (2006)Google Scholar
  10. 10.
    Du Bois, B., Demeyer, S., Verelst, J.: Refactoring—Improving Coupling and Cohesion of Existing Code. In: Proc. 11th Working Conf. Reverse Eng., pp. 144–151 (2004)Google Scholar
  11. 11.
    Mens, T., Tourwé, T.: A Survey of Software Refactoring. IEEE Trans. Software Eng. 30(2), 126–139 (2004)CrossRefGoogle Scholar
  12. 12.
    Koza, J.R.: Genetic Programming: On the Programming of Computers by Means of Natural Selection. MIT Press, Cambridge (1992)zbMATHGoogle Scholar
  13. 13.
    Kirkpatrick, S., Gelatt Jr., C.D., Vecchi, M.P.: Optimization by simulated annealing. Sciences 220(4598), 671–680 (1983)MathSciNetzbMATHCrossRefGoogle Scholar
  14. 14.
    Langer, P.: Adaptable Model Versioning based on Model Transformation By Demonstration, PhD Thesis, Vienna University of Technology (2011)Google Scholar
  15. 15.
    O’Keeffe, M., Cinnéide, M.Ó.: Search-based Refactoring for Software Maintenance. Journal of Systems and Software 81(4), 502–516Google Scholar
  16. 16.
    Ó Cinnéide, M., Tratt, L., Harman, M., Counsell, S., Hemati Moghadam, I.: Experimental assessment of software metrics using automated refactoring. In: Proceedings of the International Symposium on Empirical Software Engineering and Measurement (Septembrer 2012)Google Scholar
  17. 17.
    Hemati Moghadam, I., Cinnéide, M.Ó.: Automated refactoring using design differencing. In: Proc. of European Conference on Software Maintenance and Reengineering, Szeged (March 2012)Google Scholar
  18. 18.
    Fadhel, A.B., Kessentini, M., Langer, P., Wimmer, M.: Search-based detection of high-level model changes. In: ICSM 2012, pp. 212–221 (2012)Google Scholar
  19. 19.
  20. 20.
  21. 21.
  22. 22.
  23. 23.
    Bavota, G., De Carluccio, B., De Lucia, A., Di Penta, M., Oliveto, R., Strollo, O.: When does a Refactoring Induce Bugs? An Empirical Study. In: Proceedings of the WCRE 2012, IEEE Press (2012)Google Scholar
  24. 24.
    Harman, M., Afshin Mansouri, S., Zhang, Y.: Search-based software engineering: Trends, techniques and applications. ACM Comput. Surv. 45(1), 11 (2012)CrossRefGoogle Scholar
  25. 25.
  26. 26.
    Murphy-Hill, E., Parnin, C., Black, A.P.: How We Refactor, and How We Know It. IEEE Transactions on Software Engineering (2011)Google Scholar
  27. 27.
    Briand, L.C., Wüst, J., Daly, J.W., Victor Porter, D.: A Comprehensive Empirical Validation of Design Measures for Object-Oriented Systems. In: IEEE METRICS 1998, pp. 246–257 (1998)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2013

Authors and Affiliations

  • Rim Mahouachi
    • 1
  • Marouane Kessentini
    • 1
  • Mel Ó Cinnéide
    • 2
  1. 1.CSMissouri University of Science and TechnologyMissouriUSA
  2. 2.School of CS and InformaticsUniversity College DublinIreland

Personalised recommendations