Supervised Machine Learning for Recovering Implicit Implementation of Singleton Design Pattern

Abir Nacef, Sahbi Bahroun, Adel Khalfallah, Samir Ben Ahmed

2023

Abstract

An implicit or indirect implementation of the Singleton design Pattern (SP) is a programming implementation whose purpose is to restrict the instantiation to a single object without actually using the SP. This structure may not be faulty or errant but can impact negatively the software quality especially if they are used in inappropriate contexts. To improve the quality of the source code, the injection of the SP is sometimes mandatory. In order to assuring that, a specific structure must be identified and automatically detected. However, due to their vague and abstract nature, they can be implemented in various ways, which are not conducive to automatic and accurate detection. This paper presents the first method dedicated to the automatic detection of Singleton Implicit Implementations (SII) based on supervised Machine Learning (ML) algorithms. In this work, we define the different variants of SII, then based on the detailed definition we propose relevant features and we create a dataset named FTD (Feature Train Data) according to the corresponding variant. Based on Long Short Term Memory (LSTM) models, trained by the FTD data we extract features values from Java program. Then we create another data named SDTD (Singleton Detector Train Data) containing feature combination values to train the ML classifier. We resolve the problem of automatic detection of SII with different ML algorithms like KNN, SVM, Naive Bayes and Random Forest for classification task. Based on different public Java corpus, we create and label a data named SDED (Singleton Detector Evaluating Data), this data is used for evaluating and choosing the appropriate ML model. The empirical results prove the performance of our technique to automatically detect the SII.

Download


Paper Citation


in Harvard Style

Nacef A., Bahroun S., Khalfallah A. and Ben Ahmed S. (2023). Supervised Machine Learning for Recovering Implicit Implementation of Singleton Design Pattern. In Proceedings of the 18th International Conference on Evaluation of Novel Approaches to Software Engineering - Volume 1: ENASE, ISBN 978-989-758-647-7, SciTePress, pages 354-361. DOI: 10.5220/0011836100003464


in Bibtex Style

@conference{enase23,
author={Abir Nacef and Sahbi Bahroun and Adel Khalfallah and Samir Ben Ahmed},
title={Supervised Machine Learning for Recovering Implicit Implementation of Singleton Design Pattern},
booktitle={Proceedings of the 18th International Conference on Evaluation of Novel Approaches to Software Engineering - Volume 1: ENASE,},
year={2023},
pages={354-361},
publisher={SciTePress},
organization={INSTICC},
doi={10.5220/0011836100003464},
isbn={978-989-758-647-7},
}


in EndNote Style

TY - CONF

JO - Proceedings of the 18th International Conference on Evaluation of Novel Approaches to Software Engineering - Volume 1: ENASE,
TI - Supervised Machine Learning for Recovering Implicit Implementation of Singleton Design Pattern
SN - 978-989-758-647-7
AU - Nacef A.
AU - Bahroun S.
AU - Khalfallah A.
AU - Ben Ahmed S.
PY - 2023
SP - 354
EP - 361
DO - 10.5220/0011836100003464
PB - SciTePress