Abstract:
Software development is a continuous process that usually starts with analyzing the system requirements and proceeds with design, implementation, testing, and maintenance. Regardless of how good an initial design was achieved, quality of source code tends to decay throughout the development process as software evolves. One of the main contributing factors to this degradation of initial quality can be considered as maintenance operations, for instance to enhance performance or other attributes of the system or to fix newly discovered bugs. For such large software systems, development process also requires reusing existing components which may have been implemented by others. Hence, a comprehensible piece of source code, e.g. one that conveys its message about what it is trying to do easily with understandable and modular implementation, significantly reduces time and effort not only for the implementation phase of the development lifecycle; but also for testing and maintenance phases. In other words, while software decay is inevitable, software comprehension plays a determining role in the total cost and effectiveness of both implementation phase and maintenance phase. Therefore, developers should strive to create software components with modular structure and clearer implementation to reduce the development cost. In this paper, we are interested in finding ways to successfully decompose long methods ( those with poor initial implementation and/or decayed overtime) into smaller, more comprehensible and readable ones. This decomposition process is known as extract method refactoring and helps to reduce the overall cost of development. Most of the existing refactoring tools require users to select the code fragments that need to be extracted. We introduce a novel technique for this refactoring. This technique seeks refactoring opportunities based on variable declarations and uses confining fully extractable code regions without any user intervention. We implemented this technique as an analysis and visualization tool to help a user identify candidate code fragments to be extracted as separate methods. With this automation tool, developers do not have to manually inspect a foreign