Refactoring Using Event-based Profiling Adithya Nagarajan Department of Computer Science University of Maryland College Park, Maryland, USA sadithya@cs.umd.edu Atif Memon Department of Computer Science and Fraunhofer Center for Experimental Software Engineering University of Maryland College Park, Maryland, USA atif@cs.umd.edu Abstract Refactoring is a disciplined process of restructuring soft- ware code in order to improve it, e.g., to make it more reusable, reliable and maintainable. The source of infor- mation that guides the refactoring process may be the soft- ware’s user profiles. An increasingly important class of soft- ware is event-based software. Event-based software take an event as an input, change their state, and perhaps output an event. They provide new opportunities for refactoring. For example, reorganizing the objects related to an event and restructuring the event handlers based on the behavior of the software. These opportunities require that we collect user profiles at the level of events rather than the code and model the software in such a way that allows refactoring of event handlers. We present new techniques to collect event- level profiles and organize event handlers. We describe our techniques on one class of event-based software – Graphi- cal User Interfaces (GUIs). We demonstrate the practicality and usefulness of our techniques on a large software system. 1 Introduction Refactoring is the process of restructuring code in a dis- ciplined way [8]. It has multiple goals including improve- ment of a software’s structure for increased reusability [6], reliability [11], and maintainability [12] of code. Refactor- ing is carried out in two phases: phase one is the research and understanding phase used to identify and understand the code architecture; phase two involves using this understand- ing to actually restructure the code. The source of informa- tion required for refactoring can either be the developer’s understanding of the code or can be obtained automatically using program analysis techniques or user profiles. For example, tools such as IBM’s Eclipse [2], Refactorit [3], and Flywheel [4] perform refactoring of code automatically by analyzing the code architecture; specialized refactoring techniques such as code optimization rely on user profiles to identify hot paths in the program and use this profile in- formation to perform restructuring [5]. An increasingly important class of software is event- based software. Event-based software take an event as an input, change their state, and perhaps output an event. Com- mon examples of event-based software are Graphical User Interfaces (GUIs), Web applications and Network Proto- cols. The way that events interact in an event-based soft- ware provides new opportunities for refactoring. For exam- ple, refactoring of such software may involve reorganizing the objects related to an event and restructuring the event handlers based on the behavior of the software. Also, since most event-based software are developed using a collection of event listeners (usually implemented as methods), they provide opportunities for automatic refactoring. As event interactions are dynamic, one source of information that can be used for refactoring are user profiles of events. In this paper we describe a technique for refactoring of event-based software. Our technique involves: (1) collect- ing user profiles at the event level, (2) refactoring driven by the event level profiles, and (3) dynamic refactoring, i.e., restructuring, without access to (or need for) source code, of objects in the software with the help of a set of tools that we have developed. We describe our technique using one important class of event-based software – those with a GUI front-end. We have selected GUI based software for our study because refactoring of such software is easy to visu- alize, they are widely used, and the resulting set of tools are useful for our GUI testing software called GUITAR [1]. In the next section, we explain opportunities that GUIs provide for refactoring and the challenges involved. In Sec- tion 3, we provide details of our event-based profiling tech- nique and a dynamic GUI modeling technique. We present an evaluation study that we conducted on GUITAR in Sec- 1