|
DP-Miner A Stand-Alone Tool for Design Pattern Recovery |
Objective
Design Patterns, as good solutions to recurring problems, are proved practically important and useful in the process of software development. They have been extensively applied in industry. They help to record design tradeoff, capture design decisions, and reuse expert experience. Many current software systems embed design pattern instances in system source code. When design patterns are applied and implemented in a system, however, the pattern-related information is usually lost in the source code. It is hard to trace such design information in source code. Recovering design pattern instances from system source code can greatly help to understand the systems and change them in the future.
DP-Miner
DP-Miner is intended to recover design patterns applied in software from source code. DP-Miner analyze structural, behavioral, and semantic characteristics of system and patterns. In structural analysis, DP-Miner presents system structure in a matrix with the columns and rows to be all classes in the system. The value of each cell represents the relationships among the classes. The structure of each design pattern is similarly represented in another matrix. The discovery of design patterns from source code becomes matching between the two matrices. If the pattern matrix matches the system matrix, a candidate instance of the pattern is found. Besides matrix, DP-Miner uses weight to represent the attributes/operations of each class and its relationships with other classes and compares system class weight to pattern class weight.
The latest version of DP-Miner is available here.
Currently it is able to recover four patterns, namely, Adapter, Bridge, Composite, and Strategy, from software that are written in Java. We already conducted experiments on four open source systems, Java.Awt, JUnit, JEdit, and JHotDraw, and the result is listed below.
Experiment Result
We have conducted experiments on four open-source systems, namely Java.awt package, JUnit, JEdit, JHotDraw.
Table 1 Experiment Result of Detecting Strategy Pattern in JHotDraw
|
|
CONTEXT |
STRATEGY |
CONCRETE STATERGY |
|
|
[0] |
DrawApplet |
Drawing |
StandardDrawing |
T |
|
[1] |
DrawApplet |
Tool |
UndoableTool |
T |
|
[2] |
DrawApplet |
DrawingView |
StandardDrawingView, NullDrawingView |
F |
|
[3] |
PaletteButton |
PaletteListener |
DrawApplet, DrawApplication |
T |
|
[4] |
StorageFormatManager |
StorageFormat |
StandardStorageFormat |
T |
|
[5] |
UndoableAdapter |
DrawingView |
StandardDrawingView, NullDrawingView |
F |
|
[6] |
CommandButton |
Command |
UndoableCommand |
T |
|
[7] |
StandardVersionControlStrategy |
VersionRequester |
DrawApplet, DrawApplication |
T |
|
[8] |
UndoableHandle |
DrawingView |
StandardDrawingView, NullDrawingView |
T |
|
[9] |
UndoRedoActivity |
Undoable |
UndoableAdapter |
T |
|
[10] |
ToolButton |
Tool |
UndoableTool |
T |
|
[11] |
SelectionTool |
Tool |
UndoableTool |
T |
|
[12] |
AbstractTool |
DrawingEditor |
DrawApplet, DrawApplication, JavaDrawViewer |
T |
|
[13] |
AbstractTool |
DrawingView |
StandardDrawingView, NullDrawingView |
T |
|
[14] |
EventDispatcher |
Tool |
UndoableTool |
F |
|
[15] |
ConnectionTool |
ConnectionFigure |
LineConnection |
T |
|
[16] |
UndoActivity |
ConnectionFigure |
LineConnection |
T |
|
[17] |
AbstractCommand |
DrawingEditor |
DrawApplet, DrawApplication, JavaDrawViewer |
T |
|
[18] |
EventDispatcher |
Command |
UndoableCommand |
F |
|
[19] |
StandardDrawingView |
DrawingEditor |
DrawApplet, DrawApplication, JavaDrawViewer |
T |
|
[20] |
StandardDrawingView |
Drawing |
StandardDrawing |
T |
|
[21] |
StandardDrawingView |
Painter |
BufferedUpdateStrategy, FastBufferedUpdateStrategy, NullPainter, SimpleUpdateStrategy, ZoomUpdateStrategy, ClippingUpdateStrategy, PatternPainter |
T |
|
[22] |
StandardDrawingView |
PointConstrainer |
GridConstrainer |
T |
|
[23] |
DrawingViewKeyListener |
Command |
UndoableCommand |
T |
|
[24] |
AbstractFigure |
FigureChangeListener |
FigureChangeAdapter, FigureChangeEventMulticaster, HTMLTextAreaFigure, TextAreaFigure, TextFigure |
T |
|
[25] |
ChangeConnectionHandle |
ConnectionFigure |
LineConnection |
T |
|
[26] |
ConnectionHandle |
ConnectionFigure |
LineConnection |
T |
|
[27] |
DeleteFromDrawingVisitor |
Drawing |
StandardDrawing |
T |
|
[28] |
FigureAndEnumerator |
FigureEnumeration |
FigureEnumerator, ReverseFigureEnumerator, SingleFigureEnumerator |
T |
|
[29] |
HandleTracker |
Handle |
UndoableHandle |
T |
|
[30] |
HandleAndEnumerator |
HandleEnumeration |
HandleEnumerator |
T |
|
[31] |
InsertIntoDrawingVisitor |
Drawing |
StandardDrawing |
T |
|
[32] |
NullDrawingView |
DrawingEditor |
DrawApplet, DrawApplication, JavaDrawViewer |
T |
|
[33] |
DrawApplication |
Tool |
UndoableTool |
T |
|
[34] |
DrawApplication |
DrawingView |
StandardDrawingView, NullDrawingView |
T |
|
[35] |
DrawApplication |
Desktop |
MDIDesktopPane, JPanelDesktop, JScrollPaneDesktop, SplitPaneDesktop |
T |
|
[36] |
DragNDropTool |
Tool |
UndoableTool |
T |
|
[37] |
JHDDragSourceListener |
DrawingEditor |
DrawApplet, DrawApplication, JavaDrawViewer |
T |
|
[38] |
JHDDragSourceListener |
Undoable |
UndoableAdapter, UndoRedoActivity |
T |
|
[39] |
JHDDropTargetListener |
DrawingEditor |
DrawApplet, DrawApplication, JavaDrawViewer |
T |
|
[40] |
JHDDropTargetListener |
DrawingView |
StandardDrawingView, NullDrawingView |
T |
|
[41] |
JHDDropTargetListener |
Undoable |
UndoableAdapter, UndoRedoActivity |
T |
|
[42] |
DisposableResourceManagerFactory |
DisposableResourceHolder |
StandardDisposableResourceHolder |
T |
|
[43] |
DisposableResourceManagerFactory |
DisposableResourceManager |
StandardDisposableResourceManager |
T |
|
[44] |
ETSLADisposalStrategy |
DisposableResourceManager |
StandardDisposableResourceManager |
T |
|
[45] |
HTMLTextAreaFigure |
DisposableResourceHolder |
StandardDisposableResourceHolder |
T |
|
[46] |
StandardDisposableResourceManager |
ResourceDisposabilityStrategy |
ETSLADisposalStrategy |
T |
|
[47] |
TextHolderContentProducer |
TextHolder |
TextAreaFigure, TextFigure |
T |
|
[48] |
ZoomTool |
Tool |
UndoableTool |
T |
|
[49] |
CommandCheckBoxMenuItem |
Command |
UndoableCommand |
T |
|
[50] |
CommandMenuItem |
Command |
UndoableCommand |
T |
|
[51] |
CompositeFigureCreationTool |
CompositeFigure |
StandardDrawing, GraphicalCompositeFigure, PertFigure |
T |
|
[52] |
MDIDesktopPane |
DrawingView |
StandardDrawingView, NullDrawingView |
T |
|
[53] |
DesktopEventService |
DrawingView |
StandardDrawingView, NullDrawingView |
F |
|
[54] |
GraphicalCompositeFigure |
Layouter |
HTMLLayouter, SimpleLayouter |
T |
|
[55] |
MiniMapView |
DrawingView |
StandardDrawingView, NullDrawingView |
T |
|
[56] |
NestedCreationTool |
CompositeFigure |
StandardDrawing |
T |
|
[57] |
SimpleLayouter |
Layoutable |
GraphicalCompositeFigure |
T |
|
[58] |
TextAreaTool |
TextHolder |
TextAreaFigure, TextFigure |
T |
|
[59] |
WindowMenu |
Command |
UndoableCommand |
T |
|
[60] |
TextTool |
TextHolder |
TextAreaFigure, TextFigure |
T |
|
[61] |
Animator |
DrawingView |
StandardDrawingView, NullDrawingView |
T |
|
[62] |
Animator |
Animatable |
AnimationDecorator, BouncingDrawing |
T |
|
[63] |
JavaDrawViewer |
Drawing |
StandardDrawing |
F |
Table 2 Manually Found Strategy Pattern Instances in JHotDraw that are missed by DP-Miner
|
|
CONTEXT |
STRATEGY |
|
[1] |
LineConnection |
Connector |
|
[2] |
ChangeConnectionHandle |
Connector |
|
[3] |
ConnectionTool |
Connector |
|
[4] |
PolygonHandle |
Locator |
|
[5] |
LocatorHandle |
Locator |
|
[6] |
LocatorConnector |
Locator |
|
[7] |
SelectionTool |
DrawingView |