🤖 AI Summary
Cross-language design pattern detection suffers from high adaptation costs, poor consistency, and maintenance difficulties due to language-specific analyses. Method: This paper proposes a multi-language detection paradigm based on Virtual Abstract Syntax Trees (Virtual ASTs) and implements it in the tool DP-LARA. Leveraging the LARA multi-language framework, DP-LARA uniformly maps Java and C/C++ source code to a language-agnostic Virtual AST representation, enabling pattern recognition via static analysis and an extensible rule engine. Contribution/Results: To our knowledge, this is the first approach achieving cross-language reuse of design pattern detection logic. Empirical evaluation on Java and C/C++ projects demonstrates high accuracy and strong consistency across languages. Language extension effort decreases by approximately 60%, while maintenance overhead for existing language support is significantly reduced. DP-LARA thus provides an efficient, scalable infrastructure for multi-language software architecture analysis.
📝 Abstract
Code comprehension is often supported by source code analysis tools that provide more abstract views over software systems, such as those detecting design patterns. These tools encompass analysis of source code and ensuing extraction of relevant information. However, the analysis of the source code is often specific to the target programming language. We propose DP‐LARA, a multilanguage pattern detection tool that uses the multilanguage capability of the LARA framework to support finding pattern instances in a code base. LARA provides a virtual AST, which is common to multiple OOP programming languages, and DP‐LARA then performs code analysis of detecting pattern instances on this abstract representation. We evaluate the detection performance and consistency of DP‐LARA with a few software projects. Results show that a multilanguage approach does not compromise detection performance, and DP‐LARA is consistent across the languages we tested it for (i.e., Java and C/C++). Moreover, by providing a virtual AST as the abstract representation, we believe to have decreased the effort of extending the tool to new programming languages and maintaining existing ones.