بازآرایی تکاملی چندهدفه آگاه از انرژی برای تصحیح نشانه‌های کد بد در کاربردهای اندرویدی

نوع مقاله : مقاله پژوهشی

نویسندگان

دانشکده مهندسی کامپیوتر، دانشگاه صنعتی خواجه نصیرالدین طوسی، تهران، ایران.

چکیده

در میان مباحث حوزه مهندسی نرم‌افزار، بهره‌وری انرژی از عوامل موثر در دو مرحله توسعه و نگهداری نرم‌افزار، به مخصوص در دستگاه‌های با انرژی محدود است. انجام بازآرایی نرم‌افزار، اگرچه بهبود کیفی نرم‌افزار را به دنبال دارد، اما برخی از پژوهش‌های اخیر تصریح دارد که اعمال عملگرهای بازآرایی ممکن است به مصرف انرژی بیشتر و یا افزایش زمان اجرای برنامه‌های کاربردی اندرویدی منجر شود. در این مقاله، تاثیر بازآرایی و حذف هشت نشانه کد بد و پادالگوی اندرویدی/ جاوایی را بر زمان اجرا، مصرف انرژی و معیارهای کیفی کد بررسی می‌کنیم. برای انجام بررسی‌ها و دریافت نتایج از پنج برنامه کاربردی اندرویدی متن‌باز و یک برنامه کاربردی اندرویدی توسعه داده شده، استفاده کردیم. در گام نخست، تغییرهای میزان مصرف انرژی، زمان اجرای برنامه کاربردی و معیارهای کیفی کد را پیش و پس از انجام بازآرایی محاسبه کردیم. نتایج نشان می‌دهد اعمال بازآرایی در برخی موارد منجر به کاهش مصرف انرژی و زمان اجرا و در برخی دیگر، افزایش مصرف انرژی و زمان اجرای برنامه کاربردی را رقم زده است. در گام دوم برای ارائه پیشنهاد مجموعه‌ای از عملگرهای بازآرایی از میان عملگرهای بازآرایی تشخیص داده شده و ممکن، راهکاری تازه، با استفاده از راهکار بهینه‌سازی تکاملی چندهدفه ارائه شده است. بر همین اساس، الگوریتم ژنتیک چندهدفه با مرتب‌سازی غیرمغلوب (NSGA-II) را با در نظرگرفتن سه هدف بهبود زمان اجرا، مصرف انرژی و میزان تلاش انجام شده برای بازآرایی، به کار بردیم. خروجی این رویکرد توانسته است میزان زمان اجرا و مصرف انرژی را با دقت میانه 76% و 65% بهبود دهد و به طور میانه 42% پادالگوها و نشانه‌های کد بد تشخیص‌داده شده در برنامه‌های کاربردی اندرویدی را برطرف سازد.

کلیدواژه‌ها

موضوعات


عنوان مقاله [English]

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

نویسندگان [English]

  • Maede Zamzame
  • Saeed Sedighian Kashi
  • Amin Nikanjam
Faculty of Computer Engineering, K. N. Toosi University of Technology, Tehran, Iran.
چکیده [English]

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%.

کلیدواژه‌ها [English]

  • Genetic algorithm
  • Software refactoring
  • Search-based software engineering
  • Android applications
  • Anti-patterns
  • Bad code smell
  • Energy consumption
  • Execution time
[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