Identifying Fragments to be Extracted from Long Methods

  • Authors:
  • Limei Yang;Hui Liu;Zhendong Niu

  • Affiliations:
  • -;-;-

  • Venue:
  • APSEC '09 Proceedings of the 2009 16th Asia-Pacific Software Engineering Conference
  • Year:
  • 2009

Quantified Score

Hi-index 0.00

Visualization

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.