Understanding the modular structure of source code is a major challenge in software maintenance. Clustering classes into modules can assist reverse engineering, but its effectiveness depends on feature selection. This study compares the contribution of structural and semantic features to the cohesion of clustering results. Five projects developed using an object-oriented approach of varying sizes are used as test cases. K-means is run 50 times for each scenario, with the number of clusters fixed to the number of original packages. Structural features produce clusters with the highest internal cohesion across all projects, but their alignment with original packages is low. In contrast, semantic features yield very low internal cohesion; however, on three projects they are statistically more aligned with original packages compared to structural features. Feature combination does not provide meaningful improvement; semantic features tend to reduce cohesion without increasing package alignment. These findings indicate that no single feature type is universally best; feature selection must consider project characteristics and the intended goal
Copyrights © 2026