Identifying fragments to be extracted from long methods

Limei Yang, Hui Liu, Zhendong Niu*

*Corresponding author for this work

Research output: Chapter in Book/Report/Conference proceedingConference contributionpeer-review

30 Citations (Scopus)

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.

Original languageEnglish
Title of host publicationProceedings - 16th Asia-Pacific Software Engineering Conference, APSEC 2009
Pages43-49
Number of pages7
DOIs
Publication statusPublished - 2009
Event16th Asia-Pacific Software Engineering Conference, APSEC 2009 - Penang, Malaysia
Duration: 1 Dec 20093 Dec 2009

Publication series

NameProceedings - Asia-Pacific Software Engineering Conference, APSEC
ISSN (Print)1530-1362

Conference

Conference16th Asia-Pacific Software Engineering Conference, APSEC 2009
Country/TerritoryMalaysia
CityPenang
Period1/12/093/12/09

Keywords

  • Bad smells
  • Extract method
  • Long method
  • Refactoring

Fingerprint

Dive into the research topics of 'Identifying fragments to be extracted from long methods'. Together they form a unique fingerprint.

Cite this