skip to main content
research-article

Model‐based source code refactoring with interaction and visual cues

Published: 13 July 2023 Publication History

Abstract

Refactoring source code involves the developer in a myriad of program detail that can obscure the design changes that they actually wish to bring about. On the other hand, refactoring a UML model of the code makes it easier to focus on the program design, but the burdensome task of applying the refactorings to the source code is left to the developer. In an attempt to obtain the advantages of both approaches, we propose a refactoring approach where the interaction with the developer takes place at the model level, but the actual refactoring occurs on the source code itself. We call this approach model‐based source code refactoring and implement it in this paper using two tools: (1) Design‐Imp enables the developer to use interactive search‐based design exploration to create a UML‐based desired design from an initial design extracted from the source code. It also provides visual cues to improve developer comprehension during the design‐level refactoring process and to help the developer to discern between promising and poor refactoring solutions. (2) Code‐Imp then refactors the original source so that it has the same functional behavior as the original program, and a design close to the one produced in the design exploration phase, that is, a design that has been confirmed as “desirable” by the developer. We evaluated our approach involving interaction and visual cues with industrial developers refactoring three Java projects, comparing it with an approach using interaction without visual cues and a fully automated approach. The results show that our approach yields refactoring sequences that are more acceptable both to the individual developer and to a set of independent expert refactoring evaluators. Furthermore, our approach removed more code smells and was evaluated very positively by the experiment participants.

Graphical Abstract

We present an interactive model‐based source code refactoring approach that combines qualitative and quantitative evaluation criteria that improve the identification of refactoring opportunities as well as enhance developer assessment of refactoring value. Initially a UML‐like design model is extracted from the source code and used by an evolutionary algorithm to produce a refactored model. Proposed refactorings are highlighted using visual cues and presented to the developer for their evaluation. Developer feedback is included in the later iterations of the algorithm. The source code is finally refactored based on the refactorings accepted by the developer. Our experimental results show that this approach yields refactoring sequences that are more acceptable both to the individual developer and to a set of independent expert refactoring evaluators. Furthermore, our approach removes more code smells and was evaluated very positively by the experiment participants.

References

[1]
Murphy‐Hill E, Parnin C, Black AP. How we refactor, and how we know it. IEEE Trans Softw Eng. 2012;38(1):5‐18.
[2]
Murphy‐Hill E, Black AP. Refactoring tools: fitness for purpose. IEEE Softw. 2008;25(5):38‐44.
[3]
Bourquin F, Keller RK. High‐impact refactoring based on architecture violations. In: Proceedings of the 11th European Conference on Software Maintenance and Reengineering. IEEE; 2007:149‐158.
[4]
Liu H, Ma Z, Shao W, Niu Z. Schedule of bad smell detection and resolution: a new way to save effort. IEEE Trans Softw Eng. 2012;38(1):220‐235.
[5]
Foster SR, Griswold WG, Lerner S. WitchDoctor: IDE support for real‐time auto‐completion of refactorings. In: Proceedings of the 34th International Conference on Software Engineering. IEEE; 2012:222‐232.
[6]
Vakilian M, Chen N, Negara S, Rajkumar BA, Bailey BP, Johnson RE. Use, disuse, and misuse of automated refactorings. In: Proceedings of the 34th International Conference on Software Engineering. IEEE; 2012:233‐243.
[7]
Pizka M. Straightening spaghetti‐code with refactoring? In: Proceedings of the International Conference on Software Engineering Research and Practice. CSREA Press; 2004:846‐852.
[8]
Seng O, Stammel J, Burkhart D. Search‐based determination of refactorings for improving the class structure of object‐oriented systems. In: Proceedings of the 8th Annual Conference on Genetic and Evolutionary Computation. ACM; 2006:1909‐1916.
[9]
Harman M, Tratt L. Pareto optimal search based refactoring at the design level. In: Proceedings of the 9th Annual Conference on Genetic and Evolutionary Computation. ACM; 2007:1106‐1113.
[10]
O'Keeffe M, Ó Cinnéide M. Search‐based refactoring for software maintenance. J Syst Softw. 2008;81(4):502‐516.
[11]
Kessentini M, Mahaouachi R, Ghedira K. What you like in design use to correct bad‐smells. Softw Qual J. 2013;21(4):551‐571.
[12]
Ouni A, Kessentini M, Sahraoui H, Boukadoum M. Maintainability defects detection and correction: a multi‐objective approach. Autom Softw Eng. 2013;20(1):47‐79.
[13]
Ouni A, Kessentini M, Sahraoui H, Hamdi MS. Search‐based refactoring: towards semantics preservation. In: Proceedings of 28th IEEE International Conference on Software Maintenance. IEEE; 2012:347‐356.
[14]
Mantyla MV. An experiment on subjective evolvability evaluation of object‐oriented software: explaining factors and interrater agreement. In: Proceedings of the International Symposium on Empirical Software Engineering. IEEE; 2005:287‐296.
[15]
Hemati Moghadam I. Interactive software design improvement using metrics‐driven, multi‐level automated refactoring. PhD Thesis: University College Dublin; 2014.
[16]
Alizadeh V, Kessentini M, Mkaouer MW, Ó Cinnéide M, Ouni A, Cai Y. An interactive and dynamic search‐based approach to software refactoring recommendations. IEEE Trans Softw Eng. 2018;46(9):932‐961.
[17]
Ramirez A, Romero JR, Simons CL. A systematic review of interaction in search‐based software engineering. IEEE Trans Softw Eng. 2019;45(8):760‐781.
[18]
Ferreira TN, Vergilio SR, de Souza JT. Incorporating user preferences in search‐based software engineering: a systematic mapping study. Inform Softw Technol. 2017;90:55‐69.
[19]
Wang H, Kessentini M, Ouni A. Interactive refactoring of web service interfaces using computational search. IEEE Trans Serv Comput. 2021;14(1):179‐192.
[20]
Rebai S, Alizadeh V, Kessentini M, Fehri H, Kazman R. Enabling decision and objective space exploration for interactive multi‐objective refactoring. IEEE Trans Softw Eng. 2020;48(5):1560‐1578.
[21]
Scanniello G, Gravino C, Genero M, et al. Do software models based on the UML aid in source‐code comprehensibility? Aggregating evidence from 12 controlled experiments. Empir softw Eng. 2018;23(5):2695‐2733.
[22]
Arisholm E, Briand LC, Hove SE, Labiche Y. The impact of UML documentation on software maintenance: an experimental evaluation. IEEE Trans Softw Eng. 2006;32(6):365‐381.
[23]
Haendler T. On using UML diagrams to identify and assess software design smells. In: Proceedings of the 13th International Conference on Software Technologies. SciTePress; 2018:413‐421.
[24]
Simons CL, Parmee IC, Gwynllyw R. Interactive, evolutionary search in upstream object‐oriented class design. IEEE Trans Softw Eng. 2010;36(6):798‐816.
[25]
Jensen AC, Cheng BHC. On the use of genetic programming for automated refactoring and the introduction of design patterns. In: Proceedings of the 12th Annual Conference on Genetic and Evolutionary Computation. ACM; 2010:1341‐1348.
[26]
Simons CL, Parmee IC. Elegant object‐oriented software design via interactive, evolutionary computation. IEEE Trans Syst Man, Cybern: Part C ‐ Appl. 2012;42(6):1798‐1805.
[27]
Ghannem A, El‐Boussaidi G, Kessentini M. Model refactoring using interactive genetic algorithm. In: Proceedings of the 5th International Symposium on Search Based Software Engineering. Springer, Berlin, Heidelberg; 2013:96‐110.
[28]
Mansoor U, Kessentini M, Wimmer M, Deb K. Multi‐view refactoring of class and activity diagrams using a multi‐objective evolutionary algorithm. Softw Qual J. 2017;25(2):473‐501.
[29]
O'Keeffe M, Ó Cinnéide M. Search‐based refactoring: an empirical study. J Softw Mainten Evol. 2008;20(5):345‐364.
[30]
Alizadeh V, Kessentini M. Reducing interactive refactoring effort via clustering‐based multi‐objective search. In: Proceedings of the 33rd IEEE/ACM International Conference on Automated Software Engineering. IEEE; 2018:464‐474.
[31]
Simons C. Interactive evolutionary computing in early lifecycle software engineering design. PhD Thesis: University of the West of England; 2011.
[32]
Hemati Moghadam I, Ó Cinnéide M. Automated refactoring using design differencing. In: Proceedings of the 16th European Conference on Software Maintenance and Reengineering. IEEE; 2012:43‐52.
[33]
Deb K, Jain H. An evolutionary many‐objective optimization algorithm using reference‐point‐based nondominated sorting approach, part I: solving problems with box constraints. IEEE Trans Evol Comput. 2014;18(4):577‐601.
[34]
Deb K, Pratap A, Agarwal S, Meyarivan TAMT. A fast and elitist multiobjective genetic algorithm: NSGA‐II. IEEE Trans Evol Comput. 2002;6(2):182‐197.
[35]
Mkaouer MW, Kessentini M, Bechikh S, Deb K, Ó Cinnéide M. High dimensional search‐based software engineering: finding tradeoffs among 15 objectives for automating software refactoring using NSGA‐III. In: Proceedings of the 2014 Annual Conference on Genetic and Evolutionary Computation. ACM; 2014:1263‐1270.
[36]
Ouni A, Kessentini M, Ó Cinnéide M, Sahraoui H, Deb K, Inoue K. MORE: a multi‐objective refactoring recommendation approach to introducing design patterns and fixing code smells. J Softw: Evol Process. 2017;29(5):e1843.
[37]
Bibiano AC, Fernandes E, Oliveira D, et al. A quantitative study on characteristics and effect of batch refactoring on code smells. In: Proceedings of the ACM/IEEE International Symposium on Empirical Software Engineering and Measurement. IEEE; 2019:1‐11.
[38]
Fernandes E, Uchôa A, Bibiano AC, Garcia A. On the alternatives for composing batch refactoring. In: Proceedings of the 3rd IEEE/ACM International Workshop on Refactoring. IEEE; 2019:9‐12.
[39]
Mkaouer MW, Kessentini M, Bechikh S, Deb K, Ó Cinnéide M. Recommendation system for software refactoring using innovization and interactive dynamic optimization. In: Proceedings of the 29th ACM/IEEE International Conference on Automated Software Engineering. ACM/IEEE; 2014:331‐336.
[40]
Ouni A, Kessentini M, Sahraoui H, Inoue K, Deb K. Multi‐criteria code refactoring using search‐based software engineering: an industrial case study. ACM Trans Softw Eng Methodol. 2016;25(3):1‐53.
[41]
Bansiya J, Davis CG. A hierarchical model for object‐oriented design quality assessment. IEEE Trans Softw Eng. 2002;28(1):4‐17.
[42]
Lacerda G, Petrillo F, Pimenta M, Guéhéneuc YG. Code smells and refactoring: a tertiary systematic review of challenges and observations. J Syst Softw. 2020;167:110610.
[43]
Cedrim D, Garcia A, Mongiovi M, et al. Understanding the impact of refactoring on smells: a longitudinal study of 23 software projects. In: Proceedings of the 11th Joint Meeting on Foundations of Software Engineering. ACM; 2017:465‐475.
[44]
Kessentini W, Wimmer M, Sahraoui H. Integrating the designer in‐the‐loop for metamodel/model co‐evolution via interactive computational search. In: Proceedings of the 21th ACM/IEEE International Conference on Model Driven Engineering Languages and Systems. ACM; 2018:101‐111.
[45]
Model‐based source code refactoring with interaction and visual cues. https://sites.google.com/view/mular/home
[46]
Box GEP, Hunter JS, Hunter WG. Statistics for experimenters: design, discovery and innovation, Vol. 639: Wiley‐Interscience; 2005.
[47]
Kuehl RO. Design of Experiments: Statistical Principles of Research Design and Analysis: Duxbury Press; 2000.
[48]
Kessentini W, Sahraoui H, Wimmer M. Automated metamodel/model co‐evolution: a search‐based approach. Inform Softw Technol. 2019;106:49‐67.
[49]
Lin Y, Peng X, Cai Y, Dig D, Zheng D, Zhao W. Interactive and guided architectural refactoring with search‐based recommendation. In: Proceedings of the 24th ACM SIGSOFT International Symposium on Foundations of Software Engineering. ACM; 2016:535‐546.
[50]
Bjork RC. An example of object‐oriented design: an ATM simulation. http://www.cs.gordon.edu/courses/cs211/ATMExample/; 2022.
[51]
Hemati Moghadam I, Cinnéide MO, Zarepour F, Jahanmir MA. RefDetect: a multi‐language refactoring detection tool based on string alignment. IEEE Access. 2021;9:86698‐86727.
[52]
Mkaouer MW, Kessentini M, Bechikh S, Ó Cinnéide M, Deb K. On the use of many quality attributes for software refactoring: a many‐objective search‐based software engineering approach. Empir Softw Eng. 2016;21:2503‐2545.
[53]
Cliff N. Dominance statistics: Ordinal analyses to answer ordinal questions. Psychol Bull. 1993;114(3):494‐509.
[54]
Sahin D, Kessentini M, Bechikh S, Deb K. Code‐smell detection as a bilevel problem. ACM Trans Softw Eng Methodol. 2014;24(1):1‐44.
[55]
Santos JAM, Rocha‐Junior JB, Prates LCL, do Nascimento RS, Freitas MF, de Mendonça MG. A systematic review on the code smell effect. J Syst Softw. 2018;144:450‐477.
[56]
Ó Cinnéide M, Yamashita A, Counsell S. Measuring refactoring benefits: a survey of the evidence. In: Proceedings of the 1st International Workshop on Software Refactoring. Association for Computing Machinery; 2016:9‐12.
[57]
Kim J, Batory D, Dig D, Azanza M. Improving refactoring speed by 10x. In: Proceedings of the 38th International Conference on Software Engineering. ACM; 2016:1145‐1156.
[58]
Sunyé G, Pollet D, Traon YL, Jézéquel J‐M. Refactoring UML models. In: Proceedings 4th International Conference on the Unified Modeling Language, Modeling Languages, Concepts, and Tools. Springer, Berlin, Heidelberg; 2001:134‐148.
[59]
Misbhauddin M, Alshayeb M. UML model refactoring: a systematic literature review. Empir Softw Eng. 2015;20(1):206‐251.
[60]
Boussaïd I, Siarry P, Ahmed‐Nacer M. A survey on search‐based model‐driven engineering. Autom Softw Eng. 2017;24(2):233‐294.
[61]
Fourati R, Bouassida N, Abdallah HB. A metric‐based approach for anti‐pattern detection in UML designs. Computer and Information Science, Vol. 364: Springer, Berlin, Heidelberg; 2011:17‐33.
[62]
Enckevort T. Refactoring UML models: using openarchitectureware to measure UML model quality and perform pattern matching on UML models with OCL queries. In: Proceedings of the 24th ACM Conference Companion on Object Oriented Programming Systems Languages and Applications. ACM; 2009:635‐646.
[63]
Goldberg DE. Genetic algorithms in search, optimization and machine learning: Addison‐Wesley Longman Publishing Co, Inc; 1989.
[64]
Abid C, Alizadeh V, Kessentini M, do Nascimento Ferreira T, Dig D. 30 years of software refactoring research: a systematic literature review; 2020. Tech. rep. https://arxiv.org/abs/2007.02194
[65]
Baqais AAB, Alshayeb M. Automatic software refactoring: a systematic literature review. Softw Qual J. 2020;28(2):459‐502.
[66]
Mariani T, Vergilio SR. A systematic review on search‐based refactoring. Inform Softw Technol. 2017;83:14‐34.
[67]
Mohan M, Greer D. A survey of search‐based refactoring for software maintenance. J Softw Eng Res Develop. 2018;6(1):1‐52.
[68]
Tempero E, Gorschek T, Angelis L. Barriers to refactoring. Commun ACM. 2017;60(10):54‐61.
[69]
Shafiei N, Keyvanpour MR. Challenges classification in search‐based refactoring. In: Proceedings of the 6th International Conference on Web Research. IEEE; 2020:106‐112.
[70]
O'Keeffe M, Ó Cinnéide M. A stochastic approach to automated design improvement. In: Proceedings of the 2nd International Conference on Principles and Practice of Programming in Java. Computer Science Press, Inc.; 2003:59‐62.
[71]
Candela I, Bavota G, Russo B, Oliveto R. Using cohesion and coupling for software remodularization: Is it enough? ACM Trans Softw Eng Methodol. 2016;25(3):1‐28.
[72]
Simons C, Singer J, White DR. Search‐based refactoring: metrics are not enough. In: Proceedings of the International Symposium on Search Based Software Engineering. Springer; 2015:47‐61.
[73]
Ramirez A, Romero JR, Ventura S. Interactive multi‐objective evolutionary optimization of software architectures. Information Sciences. 2018;463:92‐109.
[74]
Tsantalis N, Chatzigeorgiou A. Identification of move method refactoring opportunities. IEEE Trans Softw Eng. 2009;35(3):347‐367.
[75]
Murphy GC, Notkin D, Sullivan KJ. Software reflexion models: bridging the gap between design and implementation. IEEE Trans Softw Eng. 2001;27(4):364‐380.
[76]
Golubev Y, Kurbatova Z, AlOmar EA, Bryksin T, Mkaouer MW. One thousand and one stories: a large‐scale survey of software refactoring. In: Proceedings of the 29th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering. ACM; 2021:1303‐1313.
[77]
Eilertsen AM, Murphy GC. The usability (or not) of refactoring tools. In: Proceedings of the IEEE International Conference on Software Analysis, Evolution and Reengineering. IEEE; 2021:237‐248.
[78]
Sharma T, Suryanarayana G, Samarthyam G. Challenges to and solutions for refactoring adoption: an industrial perspective. IEEE Softw. 2015;32(6):44‐51.

Recommendations

Comments

Information & Contributors

Information

Published In

cover image Journal of Software: Evolution and Process
Journal of Software: Evolution and Process  Volume 36, Issue 5
May 2024
597 pages
EISSN:2047-7481
DOI:10.1002/smr.v36.5
Issue’s Table of Contents
This is an open access article under the terms of the Creative Commons Attribution License, which permits use, distribution and reproduction in any medium, provided the original work is properly cited.

Publisher

John Wiley & Sons, Inc.

United States

Publication History

Published: 13 July 2023

Author Tags

  1. design exploration
  2. interactive
  3. model‐based refactoring
  4. search‐based refactoring
  5. visual cues

Qualifiers

  • Research-article

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • 0
    Total Citations
  • 0
    Total Downloads
  • Downloads (Last 12 months)0
  • Downloads (Last 6 weeks)0
Reflects downloads up to 01 Jan 2025

Other Metrics

Citations

View Options

View options

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media