Duplication for the Removal of Duplication
Ran Ettinger, Shmuel S. Tyszberowicz · 2016
A semantics-preserving code-motion refactoring transformation by Komondoor and Horwitz (KH) had been shown to be effective in the elimination of type-3 clones, partly thanks to its successful combination of statement reordering with duplication of predicates. According to a recent clone refactorability definition by Tsantalis, however, such a transformation is considered unacceptable whenever the given code fragments contain any statement that cannot be moved. We propose an adaptation of the KH transformation that yields refactorable results according to the definition of Tsantalis. An evaluation of this approach on real-world type-3 clones from the Java portion of the Tiarks benchmark produces promising results, demonstrating how code motion with the duplication of predicates forms an effective step towards the removal of duplication in source code.