A code clone is a code fragment that has other code fragments identical or similar to it in the source code. The presence of code clones is generally regarded as one factor that makes software maintenance more difficult. For example, if a code fragment with code clones is modified, it is necessary to consider whether each of the other code clones has to be modified as well. Removing code clones is one way of avoiding problems that arise due to the presence of code clones. This makes the source code more maintainable and more comprehensible. This paper proposes a set of metrics that suggest how code clones can be refactored. As well, the tool Aries, which automatically computes these metrics, is presented. The tool gives metrics that are indicators for certain refactoring methods rather than suggesting the refactoring methods themselves. The tool performs only lightweight source code analysis; hence, it can be applied to a large number of code lines. This paper also describes a case study that illustrates how this tool can be used. Based on the results of this case study, it can be concluded that this method can efficiently merge code clones.
INTRODUCTIONAs the size and complexity of software systems increase, maintenance tasks become more difficult and burdensome. Maintenance of software systems is defined as the modification of a software product after delivery to correct faults, to improve performance or other attributes, or to adapt the products to a modified environment [1]. Arthur stated that only one-fourth to onethird of all life-cycle costs are attributed to software development and Yip and Lam reported that 67% of the life-cycle costs are expended in the operation-maintenance phase of the life cycle [2,3].It is generally thought that the presence of code clones is one factor that makes software maintenance more difficult. A code clone is a code fragment that has identical or similar source code fragments elsewhere in the code. If a code fragment with code clones is modified, it is necessary to consider whether each of the code clones should also be modified. To automatically detect code clones, several methods have been proposed and software tools have been implemented [4][5][6][7][8].Refactoring has recently received a lot of attention. Refactoring is a set of operations to improve the maintainability, understandability, or other attributes of a software system without changing its external behavior. A code clone is one of the typical Bad Smells in the refactoring process [9]. Code clone detection can be perceived as the identification of code fragments to be refactored. From a practical standpoint, it is difficult to identify the code clones that are to be merged. Some code clones are simply unmergeable, or, if they are merged, they make the source code less understandable. Usually, large-scale software systems have complicated intertwining logics that make it difficult to identify the code clones that can be merged and how best to merge them.In this paper, a new method for merging code clones is propo...