Abstract:A number of package cohesion metrics have been proposed in the last decade, but they mainly converge on intra-package data dependencies between classes, which are inadequate to represent the semantics of packages in many cases. To address this problem, the authors first classify packages into four categories in terms of the kinds of their tasks. Next, a new package cohesion called CRC based on client usages is proposed by considering the fact that several classes are closely related if they are always reused together. And then the application areas of CRC in terms of the package classification framework are analyzed. Finally, a CRC measure called HC is presented. Compared to existing package cohesion metrics, HC considers not only intra-package but also inter-package data dependencies. It is hence able to reveal semantic relationships between classes. Furthermore, HC takes into account how the clients of a package use the package, thereby providing a finer-grain evaluation of the cohesion of a package. Experimental results demonstrates the effectiveness of HC, which likewise proves the feasibility of CRC.