
Table 8: Comparing SID results with Feature Maps results.
Methods STI SII
Correct Incorrect Correct Incorrect
FM 49 9 24 18
SID 47 11 40 2
Total 58 42
ity to recover correct instances. However, similar im-
plementations (implicit) are not fully trained by the
model, so it fails to correctly predict them. Feature
Maps recover a quiet number of SII as true positive
SP whereas these implementations can negatively af-
fect the source code quality. In contrast, and even if
the structures were very similar, the SID can distin-
guish between the two implementations (47 correct
instances from 58 SP and 40 correct instances from
42 SII).
6 CONCLUSION
In this paper, we have proposed a novel approach to
define and automatically detect the SII. Based on the
analysis of the SP intent, we define structure in that
we need to inject the SP. By defining and analyzing
different variants, we propose 21 relevant features that
can make the definition of each implementation.
For extracting feature values from the Java pro-
gram, we propose to use the LSTM models for syn-
tactical and semantic analysis. To train the LSTM, we
have created and labeled a data named FTD which is
composed of 15000 snippets of code. For the auto-
matic detection of SII, we create a classifier named
SID which uses different ML algorithms. The SID is
trained by a created and labeled data named SDTD.
The data is composed of feature combination values
according to the most existing implementation. The
global size of the data is 5000 samples.
To evaluate the created models, we collect 200
Java files from different public projects. We manu-
ally label the data used for the evaluation process. We
have selected 4 ML models for the SID and chosen
the perfect one according to their performance. The
empirical results prove that the proposed technique
can correctly recover any SII with higher accuracy
(more than 99% of precision) and outperforms the rel-
evant approach in distinguishing between both types
of SP.
In future work, we try to create more elementary
features to improve the extraction of some complex
ones. The purpose of automatic detection of the SII
is to improve the source code quality by injecting the
SP in the appropriate context. So, in future work, we
will pass on the realization of these complex types of
refactoring using ML. Beginner with the SP we try
to continue the extraction of implicit implementation
with other DPs.
REFERENCES
Chihada, A., Jalili, S., Hasheminejad, S. M. H., and Zan-
gooei, M. H. (2015). Source code and design confor-
mance, design pattern detection from source code by
classification approach. Appl. Soft Comput.
Fontana, F. A. and Zanoni, M. (2011). A tool for design
pattern detection and software architecture reconstruc-
tion. Inf. Sci., 181(7):1306–1324.
Gamma, E., Helm, R., Johnson, R., and Vlissides, J. M.
(1994). Design Patterns: Elements of Reusable
Object-Oriented Software. Addison-Wesley Profes-
sional.
Hussain, S., Keung, J., Khan, A. A., Ahmad, A., Cuomo,
S., Piccialli, F., Jeon, G., and Akhunzada, A. (2018).
Implications of deep learning for the automation of
design patterns organization. J. Parallel Distributed
Comput., pages 256–266.
Kim, H. and Boldyreff, C. (2000). A method to recover de-
sign patterns using software product metrics. In Soft-
ware Reuse: Advances in Software Reusability, 6th
International Conerence, Lecture Notes in Computer
Science. Springer.
Martin, R. C. (2002). Agile Software Development, Princi-
ples, Patterns, and Practices. Prentice-Hall.
Nazar, N., Aleti, A., and Zheng, Y. (2022). Feature-based
software design pattern detection. J. Syst. Softw.
Rasool, G., Philippow, I., and M
¨
ader, P. (2010). Design pat-
tern recovery based on annotations. Adv. Eng. Softw.,
41(4):519–526.
Satoru Uchiyama, Atsuto Kubo, H. W. Y. F. (2011). Detect-
ing design patterns in object-oriented program source
code by using metrics and machine learning. Proceed-
ings of the 5th International Workshop on Software
Quality and Maintainability.
Stencel, K. and Wegrzynowicz, P. (2008). Detection of
diverse design pattern variants. In 15th Asia-Pacific
Software Engineering Conference, pages 25–32. IEEE
Computer Society.
Thaller, H., Linsbauer, L., and Egyed, A. (2019). Fea-
ture maps: A comprehensible software representa-
tion for design pattern detection. In 26th IEEE Inter-
national Conference on Software Analysis, Evolution
and Reengineering, SANER 2019, Hangzhou, China,
February 24-27.
von Detten, M. and Becker, S. (2011). Combining clus-
tering and pattern detection for the reengineering of
component-based software systems. In 7th Interna-
tional Conference on the Quality of Software Archi-
tectures, pages 23–32. ACM.
Yu, D., Zhang, Y., and Chen, Z. (2015). A comprehensive
approach to the recovery of design pattern instances
based on sub-patterns and method signatures. J. Syst.
Softw.
Supervised Machine Learning for Recovering Implicit Implementation of Singleton Design Pattern
361