Measuring Package Cohesion Based on Context

Packages play a critical role to understand, construct and maintain large-scale software systems. As an important design attribute, cohesion can be used to predict the quality of packages. Although a number of package cohesion metrics have been proposed in the last decade, they mainly converge on intra-package data dependences between components, which are inadequate to represent the semantics of packages in many cases. To address this problem, we propose a new cohesion metric for package called SCC on the assumption that two components are related tightly if they have similar contexts. Compared to existing works, SCC uses the common context of two components to infer whether they have close relation or not, which involves both inter- and intra- package data dependences. It is hence able to reveal semantic relations between components. We demonstrate the effectiveness of SCC by case studies.