skip to main content
Primo Search
Search in: Busca Geral

An automated extract method refactoring approach to correct the long method code smell

Shahidi, Mahnoosh ; Ashtiani, Mehrdad ; Zakeri-Nasrabadi, Morteza

The Journal of systems and software, 2022-05, Vol.187, p.111221, Article 111221 [Periódico revisado por pares]

Elsevier Inc

Texto completo disponível

Citações Citado por
  • Título:
    An automated extract method refactoring approach to correct the long method code smell
  • Autor: Shahidi, Mahnoosh ; Ashtiani, Mehrdad ; Zakeri-Nasrabadi, Morteza
  • Assuntos: Code smell ; Extract method ; Graph analysis ; Long method ; Software refactoring
  • É parte de: The Journal of systems and software, 2022-05, Vol.187, p.111221, Article 111221
  • Descrição: Long Method is amongst the most common code smells in software systems. Despite various attempts to detect the long method code smell, few automated approaches are presented to refactor this smell. Extract Method refactoring is mainly applied to eliminate the Long Method smell. However, current approaches still face serious problems such as insufficient accuracy in detecting refactoring opportunities, limitations on correction types, the need for human intervention in the refactoring process, and lack of attention to object-oriented principles, mainly single responsibility and cohesion–coupling principles. This paper aims to automatically identify and refactor the long method smells in Java codes using advanced graph analysis techniques, addressing the aforementioned difficulties. First, a graph representing project entities is created. Then, long method smells are detected, considering the methods’ dependencies and sizes. All possible refactorings are then extracted and ranked by a modularity metric, emphasizing high cohesion and low coupling classes for the detected methods. Finally, a proper name is assigned to the extracted method based on its responsibility. Subsequently, the best destination class is determined such that design modularity is maximized. Experts’ opinion is used to evaluate the proposed approach on five different Java projects. The results show the applicability of the proposed method in establishing the single responsibility principle with a 21% improvement compared to the state-of-the-art extract method refactoring approaches. •Long Method is amongst the most common code smells in software systems.•The aim is to refactor long method smells using advanced graph analysis techniques.•A graph denoting project entities is created in which long method smells are detected.•All possible refactorings are then extracted and ranked by a modularity metric.•Results show a 21% improvement compared to the state-of-the-art approaches.
  • Editor: Elsevier Inc
  • Idioma: Inglês

Buscando em bases de dados remotas. Favor aguardar.