Experimental Study and Comparison of Clustering Algorithms for Function Restructuring
The structure of a function, procedure, or method may not be well designed or may deteriorate over time due to evolution. As a result, the function may contain multiple activities or the cohesion may become very low, thus it becomes difficult to understand and maintain those functions. This paper deals with restructuring of program statements inside of a function. The objective is to support the restructuring of a large or lowcohesion function into multiple higher cohesive functions. This paper adopts the hierarchical agglomerative clustering (HAC) method. We apply the method to program restructuring of industrial network software to support evolution. In addition, the paper reports a comparative study on the application of three different HAC algorithms, SLINK (single linkage), CLINK (complete linkage), and UPGMA (unweighted pair-group method using arithmetic averages) . The results reveal that the approach provides useful information for the designers to reorganize the structure of complicated or large functions. In general, UPGMA generates better clusters, especially when the software size (LOCs) or cyclomatic complexity is high. SLINK is more inconsistent. CLINK, on the other hand, usually does not work well.