• Title of article

    Automated refactoring to the Null Object design pattern

  • Author/Authors

    Gaitani، نويسنده , , Maria Anna G. and Zafeiris، نويسنده , , Vassilis E. and Diamantidis، نويسنده , , N.A. and Giakoumakis، نويسنده , , E.A.، نويسنده ,

  • Issue Information
    ماهنامه با شماره پیاپی سال 2015
  • Pages
    20
  • From page
    33
  • To page
    52
  • Abstract
    AbstractContext hecking conditionals are a straightforward solution against null dereferences. However, their frequent repetition is considered a sign of poor program design, since they introduce source code duplication and complexity that impacts code comprehension and maintenance. The Null Object design pattern enables the replacement of null-checking conditionals with polymorphic method invocations that are bound, at runtime, to either a real object or a Null Object. ive ork proposes a novel method for automated refactoring to Null Object that eliminates null-checking conditionals associated with optional class fields, i.e., fields that are not initialized in all class instantiations and, thus, their usage needs to be guarded in order to avoid null dereferences. roduce an algorithm for automated discovery of refactoring opportunities to Null Object. Moreover, we specify the source code transformation procedure and an extensive set of refactoring preconditions for safely refactoring an optional field and its associated null-checking conditionals to the Null Object design pattern. The method is implemented as an Eclipse plug-in and is evaluated on a set of open source Java projects. s l refactoring candidates are discovered in the projects used in the evaluation and their refactoring lead to improvement of the cyclomatic complexity of the affected classes. The successful execution of the projects’ test suites, on their refactored versions, provides empirical evidence on the soundness of the proposed source code transformation. Runtime performance results highlight the potential for applying our method to a wide range of project sizes. sion thod automates the elimination of null-checking conditionals through refactoring to the Null Object design pattern. It contributes to improvement of the cyclomatic complexity of classes with optional fields. The runtime processing overhead of applying our method is limited and allows its integration to the programmer’s routine code analysis activities.
  • Keywords
    Null Object , Refactoring , design patterns , Optional fields , Null checks
  • Journal title
    Information and Software Technology
  • Serial Year
    2015
  • Journal title
    Information and Software Technology
  • Record number

    2375418