Using Contextual Information to Assess Package Cohesion
María Laura Ponisio, Oscar Nierstrasz · Bern Open Repository and Information System (University of Bern)
Complex systems are decomposed into cohesive packages with the goal of limiting the scope of changes: if our packages are cohesive, we hope that changes will be limited to the packages responsible for the features we are changing, or at worst the packages that are immediate clients of those features. But how should we measure cohesion? Traditional cohesion metrics focus on the explicit dependencies and interactions between the classes within the package under study. A package, however, may be conceptually cohesive even though its classes exhibit no explicit dependencies. We propose a group of contextual metrics that assess the cohesion of a package based on the degree to which its classes are used together by common clients. We apply these metrics to various case studies, and contrast the degree of cohesion detected with that of traditional cohesion metrics. In particular, we note that object-oriented frameworks may appear not to be cohesive with traditional metrics, whereas our contextual metrics expose the implicit cohesion that results from the framework's clients.