Generierung von statischen und dynamischen Analysen zur Erkennung von Entwurfsmustern
We generate static and dynamic analysis algorithms from design pattern specifications to detect design patterns in legacy code. To specify
design patterns accordingly, we define two languages: a powerful, extensible, low-level language called SanD-Prolog consisting of Prolog predicates that specify the static structure and dynamic behavior of design
patterns and a high-level language SanD that allows to specify design patterns intuitively. We implemented a simple compiler that transforms SanD specifications into SanD-Prolog specifications. The static analysis is performed on the Prolog database representing the source programs' attributed abstract syntax trees
by a Prolog query derived from the SanD-Prolog specification. The result is a set of candidate tuples that are further classified by the dynamic analysis according to the patterns' behavioral specification. The behavioral specification consists of SanD-Prolog predicates simulating the execution of a pattern instance. Violation of the rules leads to rejection of the candidate instance. We use the degree of conformance of a candidate instance to classify it. The analyses do not depend on coding or naming conventions. We demonstrate our approach detecting instances of the Observer, Composite and
Decorator patterns in Java code.