Design patterns are invaluable for software engineers because they help obtain well-structured and reusable object-oriented software components and contribute towards ease of software comprehension, maintenance, and modification. However, identifying design patterns from an inspection of the source code is not easy because, in most cases, there are no syntactic cues that signal their presence. This topic has therefore elicited considerable interest in the field. The novel aspect of our work is that we propose a set of primitives using which we can declaratively specify design patterns based on a combination of static and dynamic information. Our experimental work is carried out in the context of Java: static information is extracted from Java source code, and dynamic information from an execution trace of a program. Each declarative pattern specification is automatically translated into an SQL query which retrieves all instances of the design pattern present in the program. We illustrate our approach with the well-known Gang-of-Four design patterns and the approach extends to other such design patterns. The experimental results show the efficacy of our approach for representative programs for all GoF patterns in addition to more extensive case studies, JHotDraw, Junit, and QuickUML.
Read full abstract