journal article·2025-08-24Open access

Cross-Language Code Smell Detection via Transfer Learning

Rana Sandouka, Hamoud Aljamaan

Applied Sciences· Volume 15· Issue 17

Abstract

Code smells are code structures that indicate a potential issue in code design or implementation. These issues could affect the processes of code testing and maintenance, and overall software quality. Therefore, it is important to detect code smells in the early stages of software development to enhance system quality. Most studies have focused on detecting code smells of a single programming language. This article explores TL for cross-language code smell detection, where Java is the source, and both C# and Python are the target datasets, focusing on Large Class, Long Method, and Long Parameter List code smells. We conducted a comparison study across two transfer learning approaches—instance-based (Importance Weighting Classifier, Nearest Neighbors Weighting, and Transfer AdaBoost) and parameter-based (Transfer Tree, Transfer Forest)—with various base models. The results showed that the instance-based approach outperformed the parameter-based approach, particularly with Transfer AdaBoost using ensemble learning base models. The Transfer AdaBoost approach with Gradient Boosting and Extra Trees achieved consistent and robust results across both C# and Python, with an 83% winning rate, as indicated by the Wilcoxon signed-rank test. These findings underscore the effectiveness of transfer learning for cross-language code smell detection, supporting its generalizability across different programming languages.
Source: crossref · Quality: baseline

Research context

OpenAlex topics: Speech Recognition and Synthesis · Speech and dialogue systems · Natural Language Processing Techniques

SciVX discovery tags are terminology-based. OpenAlex topics are source-provided classifications.

Affiliations

Information and Computer Science Department, King Fahd University of Petroleum and Minerals, Dhahran 31261, Saudi Arabia

Interdisciplinary Research Center for Finance and Digital Economy, King Fahd University of Petroleum and Minerals, Dhahran 31261, Saudi Arabia

Funding

Interdisciplinary Research Center for Finance and Digital Economy (IRC-FDE) at King Fahd University of Petroleum and Minerals (KFUPM)

References (64)

Show source-provided references
1. A survey on bad smells in codes and usage of algorithm analysis
2. Fowler, M. (2018). Refactoring: Improving the Design of Existing Code. Addison-Wesley Professional.
3. Weiss, K., Khoshgoftaar, T.M., and Wang, D. (2016). A survey of transfer learning. J. Big Data, 3.10.1186/s40537-016-0043-6 ↗
4. Transfer learning
5. A systematic review of transfer learning in software engineering10.1007/s11042-024-19756-x ↗
6. Chen, Q., Xue, B., and Zhang, M. (2019, January 10–13). Instance based transfer learning for genetic programming for symbolic regression. Proceedings of the 2019 IEEE Congress on Evolutionary Computation (CEC), Wellington, New Zealand.10.1109/CEC.2019.8790217 ↗
7. Kolcz, A., and Teo, C.H. (2009, January 16–17). Feature Weighting for Improved Classifier Robustness. Proceedings of the 6th Conference on Email and Anti-Spam (CEAS 2009), Mountain View, CA, USA.
8. Lu, N., Zhang, T., Fang, T., Teshima, T., and Sugiyama, M. (2022). Rethinking importance weighting for transfer learning. Federated and Transfer Learning, Springer.10.1007/978-3-031-11748-0_9 ↗
9. A decision-theoretic generalization of on-line learning and an application to boosting10.1006/jcss.1997.1504 ↗
10. Al-Stouhi, S., and Reddy, C.K. (2011). Adaptive Boosting for Transfer Learning Using Dynamic Updates. Machine Learning and Knowledge Discovery in Databases ECML/PKDD (1), Springer.10.1007/978-3-642-23780-5_14 ↗
11. Loog, M. (2012, January 23–26). Nearest neighbor-based importance weighting. Proceedings of the 2012 IEEE International Workshop on Machine Learning for Signal Processing, Santander, Spain.10.1109/MLSP.2012.6349714 ↗
12. Sharing is caring: An extensive analysis of parameter-based transfer learning for the prediction of building thermal dynamics10.1016/j.enbuild.2022.112530 ↗
13. Minvielle, L., Atiq, M., Peignier, S., and Mougeot, M. (2019, January 4–6). Transfer learning on decision tree with class imbalance. Proceedings of the 2019 IEEE 31st International Conference on Tools with Artificial Intelligence (ICTAI), Portland, OR, USA.10.1109/ICTAI.2019.00141 ↗
14. Code smells and refactoring: A tertiary systematic review of challenges and observations10.1016/j.jss.2020.110610 ↗
15. Menshawy, R.S., Yousef, A.H., and Salem, A. (2021, January 26–27). Code Smells and Detection Techniques: A Survey. Proceedings of the 2021 International Mobile, Intelligent, and Ubiquitous Computing Conference (MIUCC), Cairo, Egypt.10.1109/MIUCC52538.2021.9447669 ↗
16. Decor: A method for the specification and detection of code and design smells10.1109/TSE.2009.50 ↗
17. Bad smell detection using machine learning techniques: A systematic literature review10.1007/s13369-019-04311-w ↗
18. Adaptive detection of design flaws10.1016/j.entcs.2005.02.059 ↗
19. Amorim, L., Costa, E., Antunes, N., Fonseca, B., and Ribeiro, M. (2015, January 2–5). Experience report: Evaluating the effectiveness of decision trees for detecting code smells. Proceedings of the 2015 IEEE 26th International Symposium on Software Reliability Engineering (ISSRE), Gaithersbury, MD, USA.10.1109/ISSRE.2015.7381819 ↗
20. Tian, Y., Lo, D., and Sun, C. (2012, January 15–18). Information retrieval based nearest neighbor classification for fine-grained bug severity prediction. Proceedings of the 2012 19th Working Conference on Reverse Engineering, Kingston, ON, Canada.10.1109/WCRE.2012.31 ↗
21. Comparing and experimenting machine learning techniques for code smell detection10.1007/s10664-015-9378-4 ↗
22. Finding bad code smells with neural network models
23. BDTEX: A GQM-based Bayesian approach for the detection of antipatterns10.1016/j.jss.2010.11.921 ↗
24. Vaucher, S., Khomh, F., Moha, N., and Guéhéneuc, Y.G. (2009, January 13–16). Tracking design smells: Lessons from a study of god classes. Proceedings of the 2009 16th Working Conference on Reverse Engineering, Lille, France.10.1109/WCRE.2009.23 ↗
25. Wang, X., Dang, Y., Zhang, L., Zhang, D., Lan, E., and Mei, H. (2012, January 3–7). Can I clone this piece of code here?. Proceedings of the 27th IEEE/ACM International Conference on Automated Software Engineering, Essen, Germany.10.1145/2351676.2351701 ↗
26. Dewangan, S., and Rao, R.S. (2022). Code Smell Detection Using Classification Approaches. Intelligent Systems, Springer.10.1007/978-981-19-0901-6_25 ↗
27. Vatanapakorn, N., Soomlek, C., and Seresangtakul, P. (2022, January 21–23). Python code smell detection using machine learning. Proceedings of the 2022 26th International Computer Science and Engineering Conference (ICSEC), Sakon Nakhon, Thailand.10.1109/ICSEC56337.2022.10049330 ↗
28. Python code smells detection using conventional machine learning models10.7717/peerj-cs.1370 ↗
29. Chen, Z., Chen, L., Ma, W., and Xu, B. (2016, January 3–4). Detecting code smells in Python programs. Proceedings of the 2016 international conference on Software Analysis, Testing and Evolution (SATE), Kunming, China.10.1109/SATE.2016.10 ↗
30. Aljamaan, H. (2021, January 13–16). Voting Heterogeneous Ensemble for Code Smell Detection. Proceedings of the 2021 20th IEEE International Conference on Machine Learning and Applications (ICMLA), Pasadena, CA, USA.10.1109/ICMLA52953.2021.00148 ↗
31. Code smell detection using feature selection and stacking ensemble: An empirical investigation10.1016/j.infsof.2021.106648 ↗
32. Improving performance with hybrid feature selection and ensemble machine learning techniques for code smell detection10.1016/j.scico.2021.102713 ↗
33. Dynamic stacking ensemble for cross-language code smell detection10.7717/peerj-cs.2254 ↗
34. Rao, R.S., Dewangan, S., and Mishra, A. (2025). An Empirical Evaluation of Ensemble Models for Python Code Smell Detection. Appl. Sci., 15.10.3390/app15137472 ↗
35. Hadj-Kacem, M., and Bouassida, N. (2018, January 23–24). A Hybrid Approach To Detect Code Smells using Deep Learning. Proceedings of the ENASE, Setubal, Portugal.10.5220/0006709801370146 ↗
36. Deep learning based code smell detection
37. Das, A.K., Yadav, S., and Dhal, S. (2019, January 17–20). Detecting code smells using deep learning. Proceedings of the TENCON 2019—2019 IEEE Region 10 Conference (TENCON), Kochi, India.10.1109/TENCON.2019.8929628 ↗
38. Lin, T., Fu, X., Chen, F., and Li, L. (2021). A Novel Approach for Code Smells Detection Based on Deep Leaning. EAI International Conference on Applied Cryptography in Computer and Communications, Springer.10.1007/978-3-030-80851-8_12 ↗
39. Gupta, H., Kulkarni, T.G., Kumar, L., Neti, L.B.M., and Krishna, A. (2021). An empirical study on predictability of software code smell using deep learning models. International Conference on Advanced Information Networking and Applications, Springer.10.1007/978-3-030-75075-6_10 ↗
40. Code smell detection by deep direct-learning and transfer-learning10.1016/j.jss.2021.110936 ↗
41. Enhancing Python Code Smell Detection with Heterogeneous Ensembles10.1142/S0218194025500287 ↗
42. Feng, Z., Guo, D., Tang, D., Duan, N., Feng, X., Gong, M., Shou, L., Qin, B., Liu, T., and Jiang, D. (2020). Codebert: A pre-trained model for programming and natural languages. arXiv.10.18653/v1/2020.findings-emnlp.139 ↗
43. Guo, D., Ren, S., Lu, S., Feng, Z., Tang, D., Liu, S., Zhou, L., Duan, N., Svyatkovskiy, A., and Fu, S. (2020). Graphcodebert: Pre-training code representations with data flow. arXiv.
44. Ahmad, W.U., Chakraborty, S., Ray, B., and Chang, K.W. (2021). Unified pre-training for program understanding and generation. arXiv.10.18653/v1/2021.naacl-main.211 ↗
45. A survey on transfer learning10.1109/TKDE.2009.191 ↗
46. Cariucci, F.M. (2024, November 18). ADAPT: Python Toolbox for Domain Adaptation. Version 0.4.4. Available online: https://adapt-python.github.io/adapt/index.html.
47. Overflow, S. (2025, August 20). Stack Overflow. Available online: https://survey.stackoverflow.co/2024.
48. Using java and C# programming languages for server platforms and workstations
49. Python–the fastest growing programming language
50. Lanza, M., and Marinescu, R. (2006). Object-Oriented Metrics in Practice: Using Software Metrics to Characterize, Evaluate, and Improve the Design of Object-Oriented Systems, Springer.
51. Alkharabsheh, K., Crespo, Y., Fernández-Delgado, M., Cotos, J.M., and Taboada, J.A. (2019, January 10–12). Assessing the influence of size category of the project in god class detection, an experimental approach based on machine learning (MLA). Proceedings of the International Conference on Software Engineering & Knowledge Engineering, Lisbon, Portugal.10.18293/SEKE2019-140 ↗
52. Cruz, D., Santana, A., and Figueiredo, E. (2020, January 25–26). Detecting bad smells with machine learning algorithms: An empirical study. Proceedings of the 3rd International Conference on Technical Debt, Seoul, Republic of Korea.10.1145/3387906.3388618 ↗
53. Crowdsmelling: A preliminary study on using collective knowledge in code smells detection10.1007/s10664-021-10110-5 ↗
54. Yadav, P.S., Rao, R.S., Mishra, A., and Gupta, M. (2024). Machine learning-based methods for code smell detection: A survey. Appl. Sci., 14.10.3390/app14146149 ↗
55. Severity classification of software code smells using machine learning techniques: A comparative study10.1002/smr.2454 ↗
56. Empirical study of Long Parameter List code smell and refactoring tool comparison
57. The Matthews correlation coefficient (MCC) is more informative than Cohen’s Kappa and Brier score in binary classification assessment10.1109/ACCESS.2021.3084050 ↗
58. Investigating the impact of data normalization on classification performance10.1016/j.asoc.2019.105524 ↗
59. Liashchynskyi, P., and Liashchynskyi, P. (2019). Grid search, random search, genetic algorithm: A big comparison for NAS. arXiv.
60. Kohavi, R. (1995, January 20–25). A study of cross-validation and bootstrap for accuracy estimation and model selection. Proceedings of the 14th International Joint Conference on Artificial Intelligence, Montreal, QC, Canada.
61. An empirical comparison of model validation techniques for defect prediction models10.1109/TSE.2016.2584050 ↗
62. Montesinos López, O.A., Montesinos López, A., and Crossa, J. (2022). Overfitting, model tuning, and evaluation of prediction performance. Multivariate Statistical Machine Learning Methods for Genomic Prediction, Springer.10.1007/978-3-030-89010-0 ↗
63. Machine learning techniques for code smell detection: A systematic literature review and meta-analysis10.1016/j.infsof.2018.12.009 ↗
64. Chicco, D., and Jurman, G. (2020). The advantages of the Matthews correlation coefficient (MCC) over F1 score and accuracy in binary classification evaluation. BMC Genom., 21.10.1186/s12864-019-6413-7 ↗