错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

Singleton and Factory Design Patterns Detection Based on Features and Machine Learning

  • Abir Nacef,
  • Sabeur Sehimi,
  • Sahbi Bahroun,
  • Samir Ben Ahmed

摘要

Design patterns are essential for developing flexible, extensible, and easily maintainable applications that provide effective, scalable, reliable, and manageable software systems. The advantage of using patterns is to take advantage of best practices and experience in solving challenging tasks. Patterns have been extensively tested across different applications, and represent a necessity to guarantee the creation of high-quality software. In this paper, we extend our previous work [17] on Singleton pattern detection to propose a new method for recovering both Singleton and Factory pattern. The detection approach will begin through the use of features and supervised machine learning. In this work, we will identify a set of Factory non-standard variants, analyze them, select their relevant information in the form of features, analyze the Java program by the LSTM to extract feature values, and create a machine learning classifier to detect both Singleton and Factory patterns. To extract values of Factory features, we create structured data (containing snippets of code) to train the LSTM. On the other hand, to train the pattern classifier, we create another dataset (containing a feature combination values). We use different machine learning algorithms for creating the detector to compare their performance. The empirical results demonstrate that our detection method, can identify any Singleton or Factory implementation and distinct between them with highly precision, and recall rates. We have compared the proposed approach to similar studies, namely DPDf and GEML. The results show that the detector outperforms the state-of-the-art approaches by more than 21% on evaluated data constructed from different repositories; PMART, DPB and DPDf corpus in terms of standard mesures.