27.03.2014 Views

SEKE 2012 Proceedings - Knowledge Systems Institute

SEKE 2012 Proceedings - Knowledge Systems Institute

SEKE 2012 Proceedings - Knowledge Systems Institute

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Identification of Design Patterns Using Dependence<br />

Analysis<br />

Wentao Ma, Xiaoyu Zhou, Xiaofang Qi<br />

School of Computer Science and Engineering<br />

Southeast University<br />

Key Lab of Computer Network and Information Integration<br />

(Southeast University), Ministry of Education<br />

Nanjing, China<br />

Ju Qian<br />

College of Computer Science and Technology<br />

Nanjing University of Aeronautics and Astronautic<br />

Nanjing, China<br />

Lei Xu, Rui Yang<br />

Department of Computer Science and Technology<br />

Nanjing University<br />

Nanjing, China<br />

Abstract—Identification of design pattern instances in source<br />

codes facilitates software understanding and maintenance. Existing<br />

researches use three kinds of information in the identification:<br />

structure, control flow, and class or method names. In this paper,<br />

data flow information is used in identification. An approach is<br />

presented to identify instances of Adapter, State, Strategy and<br />

Observer patterns based on program dependence analysis. It<br />

brings more precise and detailed identification result. The effectiveness<br />

of the approach is illustrated by experiments on open<br />

source programs. <br />

Keywords-design pattern; program dependence; program<br />

comprehension; reverse engineering;<br />

I. INTRODUCTION<br />

GoF design patterns are widely used in practice [1]. Identification<br />

of design pattern instances (hereinafter referred to as<br />

"pattern instances" for short) in source codes recovers the design-code<br />

traceability, facilitates software understanding and<br />

maintenance.<br />

Ideally, identification of pattern instances should identify<br />

all the classes, methods and variables that play roles in the design<br />

patterns.<br />

Early researches focus on identifying pattern instances by<br />

structure information [9]. These approaches cannot distinguish<br />

design patterns having similar structures, such as State and<br />

Strategy pattern [5][6]. They are also not good at identifying<br />

methods playing roles in patterns.<br />

<br />

Supported partially by the National Natural Science Foundation of China<br />

under Grant No. 90818027, and No. 60903026, and No. 61003156, and<br />

partially supported by the Fundamental Research Funds for the Central<br />

Universities under Grant No.1116020205, and No.1118020203.<br />

Correspondence to: Xiaoyu Zhou, School of Computer Science and Engineering,<br />

Southeast University, Nanjing, China. E-mail: zhouxy@seu.edu.cn.<br />

Recently, some researches identify pattern instances by<br />

checking whether call sequences of the analyzed source codes<br />

are in accordance with that of the design patterns [7][11]. These<br />

approaches are more capable in identifying methods of design<br />

patterns. But they can't identify design patterns that have<br />

no special characteristics in method call sequences, such as<br />

Adapter pattern [5][8][13].<br />

Some few researchers identify pattern instances using semantics<br />

of th e classes or methods names [10][12]. These approaches<br />

are not mainstream in pattern instance identification<br />

research.<br />

Existing researches can only identified two kinds of variables<br />

that play roles in design patterns: (1) field of one class that<br />

refers to another class in the pattern instance; (2) method parameter<br />

or return value whose type is the class in the pattern<br />

instances. Many other variables playing roles in design patterns<br />

cannot be identified in these researches.<br />

Design patterns should be identified from multiple perspectives.<br />

The more perspectives are used, the more precise and<br />

detailed result will be obtained. As far as we know, except for<br />

our own work [2], data flow information has not yet been used<br />

in design pattern identification research. In this paper, we identify<br />

pattern instances using dependence relations in the analyzed<br />

codes. In this paper:<br />

1) We present the characteristic of dependence relations in<br />

adapting method. Both Adapter and State pattern has adapting<br />

method, but Strategy pattern doesn't. Based on the<br />

distinguishment, we identify Adapter pattern instances, and<br />

distinguish State pattern instances from that of Strategy.<br />

2) Dependence relations of variables within Notify method<br />

of Observer pattern is pres ented. Using the relations, we<br />

identify Observer instances and some variables playing roles<br />

in the pattern, such as the event objects notified to Observers,<br />

and the variables that act as targets or results of observation.<br />

289

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!