Framework for Automated Code Smell Correction in a Brownfield Context

Framework for Automated Code Smell Correction in a Brownfield Context
Internal advisor: Prof. Dr. Klaus Turowski, Christian Baumann

In the range of software development and –service gradually emerges the problem of the “fluxing” of source codes . For several reasons such as copy/paste programming, different levels of expertise among the developers, or deadlines that have to be observed and that favor overhasty or inaccurate solutions, the quality of the code is being reduced so that the further development of the code-basis becomes increasingly problematic and unhandy.

This phenomenon can be counteracted with modern methods of development such as agile software development, pair programming or test driven development, since those methods favor the continuous improvement of the code.

The relatively young principle of the Clean Code is a collection of proposals that is meant to support the developers in keeping their source codes on a constantly high level and in guarding it against expiration. Projects that have been developed during a long period and that were not created according to the rules of the Clean Code are called “Brownfield” projects, indicating that those projects are affected by declining quality. Clean Code aims at translating those projects into their orderly implemented counterpart, the so-called “Greenfield” projects. Therefore, especially great significance is attached to the repetitive examination with so-called Code Smells.

Code Smells describe parts of the source code that are syntactically and semantically correct but seem to be defective. For example, a method that has been implemented in an object-oriented surrounding can be translated in a procedural way and can be accordingly long, a so-called “Long Method”. Yet another important Code Smell is “Duplicated Code”. It shows that two parts of a program carry out the same task and that this functionality could be outsourced into an independent method.

Through this description and identification of Code Smells another field of research arises: the Refactoring. Refactoring describes a transformation process (behavior-preserving transformation) in which a program A is rewritten so that the resulting program B reliably produces the same results like the original program A. In order to guarantee the preservation of the functionality, a syntactically correct circumscription of the abstract parse tree and a semantic-preserving restructuring of the control- and dependency-flow of variables, methods and classes have to be conducted.

Currently, in literature, both phases of automated removal of Code Smell are considered separately. The goal of the work that has been published under the title “Framework for Automated Code Smell Correction in a Brownfield Context” is to find an appropriate frame for the combination of both fields of research, namely detection and correction, and to implement a framework that is able to both uncover and correct the different Code Smells automatically. In doing so, one is supposed to access already existing approaches such as DECOR by Moha et al. and combine those with current approaches of the environment of correction.