Identifying Fragments to be Extracted from Long Methods
Authors:
- Limei YangLYLimei Yang
- Hui LiuHLHui Liu
- Zhendong NiuZNZhendong Niu
- 1 December 2009
- conference paper
- Published by Institute of Electrical and Electronics Engineers (IEEE)
- p. 43-49
Abstract
Long and complex methods are hard to read or maintain, and thus usually treated as bad smells, known as Long Method. On the contrary, short and well-named methods are much easier to read, maintain, and extend. In order to divide long methods into short ones, refactoring Extract Method was proposed and has been widely used. However, extracting methods manually is time consuming and error prone. Though existing refactoring tools can automatically extract a selected fragment from its inclosing method, which fragment within a long method should be extracted has to be determined manually. In order to facilitate the decision-making, we propose an approach to recommend fragments within long methods for extraction. The approach is implemented as a prototype, called AutoMeD. With the tool, we evaluate the approach on a nontrivial open source project. The evaluation results suggest that refactoring cost of long methods can be reduced by nearly 40%. The main contribution of this paper is an approach to recommending fragments within long methods to be extracted, as well as an initial evaluation of the approach.Keywords
This publication has 1 reference indexed in Scilit:
- Program SlicingIEEE Transactions on Software Engineering, 1984