Structural design patterns address concerns related to high-level structures for applications being developed. Accurately recovered instances of structural design patterns support development related tasks like program comprehension and reengineering. However, the detection of structural design pattern instances is not always a straightforward task. The lack of documentation, the adhoc nature of programming and the possible variants of pattern instances often lead to the low accuracy of detection. In this paper, we present an approach to the detection of instances of structural design patterns using source codes. We first transform the source codes and predefined patterns into graphs, with the classes as nodes and the relations as edges. We then identify the instances of sub-patterns that would be the possible constituents of pattern instances by means of subgraph discovery. The sub-pattern instances are further merged by joint classes to see if the collective matches one of the predefined patterns. Compared with existing approaches, our approach focuses on simple subpatterns, not complicated patterns. In this way, it can not only simplify the detection process, but also detect multiple pattern instances at a time. The results of the experiments on detecting pattern instances of Adapter, Bridge, Composite, Decorator and Proxy from 4 open source software systems demonstrate that our approach obtains better precision than the existing approaches.
A bstract-Detecting design pattern instances from source codes can assist the understanding of the systems. This paper presents an approach to the detection of design patterns based on graph isomorphism. We introduce two kinds of graphs, among which one represents the system design and the other describes the design patterns to be recovered. In order to detect instances of design patterns, we first identify in system graph all the candidate classes that correspond to the pattern classes. Afterwards we select some of candidate classes to form the sub-graphs of system graph, which are then checked isomorphic to the pattern graph or not. Those isomorphic sub-graphs are regarded to be corresponding to instances of the design patterns. The detection of decorator pattern is given as the example to show the effectiveness of the approach.
scite is a Brooklyn-based organization that helps researchers better discover and understand research articles through Smart Citations–citations that display the context of the citation and describe whether the article provides supporting or contrasting evidence. scite is used by students and researchers from around the world and is funded in part by the National Science Foundation and the National Institute on Drug Abuse of the National Institutes of Health.