Detecting design patterns in source code is essential for understanding and maintaining software architectures, yet remains difficult due to variability in real-world implementations. This paper introduces a neuro-symbolic framework for design pattern detection that combines interpretable structural analysis with learned semantic representations. The approach integrates two complementary signals, i.e., topological conformance via abstract syntax tree analysis under a four-pillar heuristic, and semantic similarity to canonical pattern prototypes in a discriminative latent space. This latent space is obtained by fine-tuning CodeBERT with supervised contrastive learning, yielding cohesive and separable pattern clusters. To mitigate data scarcity and lexical bias, we generate and validate a synthetic dataset using large language models and apply identifier anonymization at the abstract syntax tree level. Evaluation on an unseen synthetic test set and on a manually validated Gold Standard benchmark demonstrates improved robustness over purely structural methods, with strong performance across standard metrics. Overall, combining structural constraints with optimised semantic representations offers a robust and scalable solution for design pattern detection in software architecture analysis.

Intelligent Detection of Design Patterns in Existing Source Code

Passaro, Lucia;Soldani, Jacopo
2026-01-01

Abstract

Detecting design patterns in source code is essential for understanding and maintaining software architectures, yet remains difficult due to variability in real-world implementations. This paper introduces a neuro-symbolic framework for design pattern detection that combines interpretable structural analysis with learned semantic representations. The approach integrates two complementary signals, i.e., topological conformance via abstract syntax tree analysis under a four-pillar heuristic, and semantic similarity to canonical pattern prototypes in a discriminative latent space. This latent space is obtained by fine-tuning CodeBERT with supervised contrastive learning, yielding cohesive and separable pattern clusters. To mitigate data scarcity and lexical bias, we generate and validate a synthetic dataset using large language models and apply identifier anonymization at the abstract syntax tree level. Evaluation on an unseen synthetic test set and on a manually validated Gold Standard benchmark demonstrates improved robustness over purely structural methods, with strong performance across standard metrics. Overall, combining structural constraints with optimised semantic representations offers a robust and scalable solution for design pattern detection in software architecture analysis.
2026
9783032391421
9783032391438
File in questo prodotto:
Non ci sono file associati a questo prodotto.

I documenti in IRIS sono protetti da copyright e tutti i diritti sono riservati, salvo diversa indicazione.

Utilizza questo identificativo per citare o creare un link a questo documento: https://hdl.handle.net/11568/1374051
 Attenzione

Attenzione! I dati visualizzati non sono stati sottoposti a validazione da parte dell'ateneo

Citazioni
  • ???jsp.display-item.citation.pmc??? ND
  • Scopus ND
  • ???jsp.display-item.citation.isi??? ND
social impact