ECSA 2024
Mon 2 - Fri 6 September 2024 Luxembourg, Luxembourg

Design patterns are standard solutions to recurrent problems in software engineering. The use of design patterns helps developers improve software quality. However, when integrating design patterns into their systems, software developers usually do not document their use. To this end, the use of an automatic approach for their detection may accelerate program comprehension, assist developers in software refactoring, and reduce efforts during the maintenance task. In this paper, we propose an attention-based approach for design pattern detection. The proposed approach utilizes an automatic feature extraction step based on the transformer architecture with an attention mechanism. Based on an unsupervised approach, this step learns from source code to identify code attributes and then produces embedding vectors. These vectors represent syntactic and semantic information related to design pattern implementations and serve as input to train a classifier for the design pattern detection task. The attention mechanism is used to generate important features representing design pattern implementations and improve the accuracy of the classification model. The evaluation shows that our classifier detected GoF design patterns with an accuracy score of 86 %, precision of 87 %, recall of 86%, and F1-score of 86 %. The comparison of our findings with state-of-the-art methods shows an improvement in (i) precision of 25 %, (ii) recall of 6 %, and (iii) F1-score of 8 %