Energy-aware evolutionary multi-objective refactoring for bad code smells correction of Android applications

Document Type : Original Article

Authors

Faculty of Computer Engineering, K. N. Toosi University of Technology, Tehran, Iran.

Abstract

Among the topics in the field of software engineering, energy efficiency is an influential factor in software development and maintenance, especially for battery-limited devices. Although software refactoring can improve software quality, recent studies suggest that applying some refactoring operators may lead to conflicts with energy consumption and execution time of Android applications. In this paper, we analyze the impact of code refactoring for eight Android/Java bad code smells and anti-patterns. To conduct the studies and obtain the results, we use a testbed of five real and one synthetic Android applications. In the first step, we measure energy consumption, execution time and quality design of application before and after refactoring. The results show that in some cases, refactoring leads to a decrease in energy consumption and execution time, and in others, it increases energy consumption and application execution time. We then propose a novel refactoring recommendation approach based on evolutionary multi-objective optimization that accounts for energy consumption, execution time and refactoring effort for Android/Java anti-patterns.  For this purpose, we use Nondominated Sorting Genetic Algorithm-II (NSGA-II) with three objectives: 1) energy consumption, 2) execution time, and 3) refactoring effort. The obtained results show that this approach can generate refactoring recommendations with a median precision of 65% and 76% for improving energy and execution time, respectively, while the median of removed antipatterns in testbed applications is 42%.

Keywords

Main Subjects


[1] I. Manotas, J. Clause, and L.L. Pollock, “Exploring Evolutionary Search Strategies to Improve Applications’ Energy Efficiency,” in Search-Based Softw. Eng. - 10th Int. Symp. (SSBSE), Montpellier, France, 2018, Proc., pp. 278-292, doi: 10.1007/978-3-319-99241-9_15.
[2] T. Mariani and S.R. Vergilio, “A systematic review on search-based refactoring,” Inf. Softw. Technol., vol. 83, pp. 14-34, 2017, doi: 10.1016/j.infsof.2016.11.009.
[3] R. Morales, R. Saborido, F. Khomh, F. Chicano, and G. Antoniol, “EARMO: An Energy-Aware Refactoring Approach for Mobile Apps,” IEEE Trans. Software Eng., vol. 44, no. 12, pp. 1176-1206, 2018, doi: 10.1109/tse.2017.2757486.
[4] H. Mumtaz, M.R. Alshayeb, S. Mahmood, and M. Niazi, “An empirical study to improve software security through the application of code refactoring,” Inf. Softw. Technol., vol. 96, pp. 112-125, 2018, doi: 10.1016/j.infsof.2017.11.010.
[5] M. Harman, S.A. Mansouri, and Y. Zhang, “Search-based software engineering: Trends, techniques and applications,” ACM Comput. Surv., vol. 45, no. 1, pp. 1-61, 2012, doi: 10.1145/2379776.2379787.
[6] J. Fields., S. Harvie., M. Fowler., and K. Beck., Refactoring, Pearson Education, 2009, isbn: 0321604172.
[7] W.J. Brown, R.C. Malveau, H.W.S. McCormick, and T.J. Mowbray, AntiPatterns, Wiley, 1998, isbn: 0471197130.
[8] K. Deb, “Multi-objective Optimisation Using Evolutionary Algorithms: An Introduction,” in Multi-objective Evolutionary Optimisation for Product Design and Manufacturing, pp. 3-34, 2011, doi: 10.1007/978-0-85729-652-8_1. 
[9] S. Gholamshahi and S.M.H. Hasheminejad, “A method for identifying software components based on Non-dominated Sorting Genetic Algorithm,” Soft Comput. J., vol.7, no. 2, pp. 47-64, 2019, dor: 20.1001.1.23223707.1397.7.2.4.5 [In Persian].
[10] M. Hajibaba and S. Parsa, “Software Fault Localization using Cross Entropy and N-gram Models,” Soft Comput. J., vol. 2, no. 1, pp. 44-59, 2013, dor: 20.1001.1.23223707.1392.2.1.59.3 [In Persian].
[11] S. Beiranvand and M.A. Zare Chahooki, “A Review on Software Cost Estimation Based on Machine Learning,” Soft Comput. J., vol. 5, no. 1, pp. 36-65, 2017 [In Persian].
[12] M.A. Bokhari, B.R. Bruce, B. Alexander, and M. Wagner, “Deep parameter optimisation on Android smartphones for energy minimisation,” in Proc. Genet. Evol. Comput. Conf. Companion, 2017, pp. 1501-1508, doi: 10.1145/3067695.3082519.
[13] G. Hecht, N. Moha, and R. Rouvoy, “An empirical study of the performance impacts of Android code smells,” in Proc. Int. Conf. Mobile Softw. Eng. Syst. (MOBILESoft), Austin, Texas, USA, 2016, pp. 59-69, doi: 10.1145/2897073.2897100.
[14] O. Barack and L. Huang, “Effectiveness of Code Refactoring Techniques for Energy Consumption in a Mobile Environment,” in Proc. Int. Conf. Softw. Eng. Res. Practice (SERP), The Steering Committee of The World Congress in Computer Science, Computer Engineering and Applied Computing (WorldComp), Las Vegas, NV, USA, 2018, pp. 165-171.
[15] F. Palomba, D. Di Nucci, A. Panichella, A. Zaidman, and A. De Lucia, “On the impact of code smells on the energy consumption of mobile applications,” Inf. Softw. Technol., vol. 105, pp. 43-55, 2019, doi: 10.1016/j.infsof.2018.08.004.
[16] G. Hecht, R. Rouvoy, N. Moha, and L. Duchien, “Detecting Antipatterns in Android Apps,” in 2nd ACM Int. Conf. Mobile Softw. Eng. Syst. (MOBILESoft), Florence, Italy, 2015, pp. 148-149, doi: 10.1109/mobilesoft.2015.38.
[17] PMD Source Code Analyser (07 Aug. 2021), [Online]. Available: https://pmd.github.io/
[18] F-Droid - Free and Open Source Android App Repository (07 Aug. 2021), [Online]. Available: https://www.f-droid.org/
[19] Debug - Android Developers (07 Aug. 2021), [Online]. Available: https://developer.android.com/reference/android/os/Debug?hl=en
[20] J. Bansiya and C.G. Davis, “A hierarchical model for object-oriented design quality assessment,” IEEE Trans. Software Eng., vol. 28, no. 1, pp. 4-17, 2002, doi: 10.1109/32.979986.
[21] Monkeyrunner - Android Developers, Android Developers (07 Aug. 2021), [Online]. Available: https://developer.android.com/studio/test/monkeyrunner