Classes in the object-oriented paradigm are supposed to capture the essential features of objects found in a problem space. It is generally accepted that an object-oriented system which is constructed in terms of the objects instantiated from the classes will possess a high reusability and modifiability. Therefore, classes should be carefully designed to take a full advantage of the desirable features provided by classes such as data abstraction and encapsulation. It is especially so because object-oriented systems are often developed by extensively reusing the existing classes.
Cohesion refers to the degree of the interrelatedness of elements of a module, and is being used as a metric which characterizes the quality of a module. It is widely recognized that the higher the cohesion of a module is, the easier the module is to develop, maintain, and reuse, and the less fault-prone it is. This thesis defines a new cohesion measure for assessing the quality of classes and thereby evaluating the quality of a design. Our approach is based on the observations on the salient properties of classes which have not been considered in the previous approaches. First, we note that the special methods which are designed to have specific behavior and inherently interact with only a part of the instance variables have only insignificant impact on the cohesiveness of a class. Second, the existing measures do not consider the implicit relationships among class members by derived instance variables whose values can be computed from other instance variables. Finally, we also insist that the cohesion should depend not only on the number of interactions, but also on the strength of relationships among the members of a class.
Based on such observations, we introduced a notion of Most Cohesive Component(MCC) as the most cohesive form of a class which incorporate the characteristics of special methods and derived instance variables. Connectivity factor is proposed to quantify the reletedness of class members and structure factor is proposed to evaluate the cohesiveness of constituents of a class. Our new cohesion of a class is then given by a product of those two factors. We added a discussion on various ways of applying this cohesion to practical situations and a empirical study in order to demonstrate the effectiveness of this measure through an experiment with a class library by using a developed cohesion measurement tool.
클래스는 객체지향 방법론의 기본 개념으로서 자료 추상화, 계승 등의 토대가 된다. 또한 요구사항 분석, 시스템 설계 및 구현의 시스템 개발 단계에 있어서 일관된 개념으로 적용되기 때문에 객체지향 시스템의 이해도 및 유지 보수성을 향상시키는데 중요한 역할을 하고 있다. 그러나, 클래스에 의한 객체지향 시스템의 잇점은 좋은 구조의 클래스로부터 얻어질 수 있다. 따라서, 클래스 설계에 대한 품질의 척도가 필요하다.
응집도는 모듈의 구성요소들 사이의 관련성 정도를 나타내며 전통적으로 좋은 설계에 대한 척도로서 사용되어 왔다. 즉, 모듈을 설계할 때 가능한한 높은 응집도를 얻으려고 노력하며, 낮은 응집도를 가지는 모듈에 대해서는 높은 응집도를 가지도록 재구성하는 노력을 기울여 왔다. 이러한 응집도의 개념을 객체지향 방법론의 클래스에도 적용할 수가 있다. 즉, 높은 응집도의 클래스는 문제영역의 대상 또는 개념에 대한 모델링으로서 바람직하며, 반대로 낮은 응집도의 클래스는 관련성이 낮은 멤버들의 집합으로서 바람직하지 않다.
이러한 중요성 때문에 클래스의 응집도에 대한 많은 연구가 수행되고 있다. 그러나, 기존의 클래스의 응집도에 대한 척도들은 클래스 자체의 특성이 반영되지 않았기 때문에 클래스의 실제 응집도를 올바르게 평가하지 못하는 문제점을 드러내고 있다. 이 논문에서는 클래스 자체의 특성을 최대한 척도에 반영함으로써 기존의 응집도 척도가 가지는 문제점들을 해결하여 클래스의 응집도를 정확하게 평가할 수 있는 방법을 제안한다.
첫째로, 기존의 응집도 척도들은 메소드가 많은 인스턴스 변수를 참조하거나 공유 인스턴스 변수를 가지는 메소드의 쌍이 많을 수록 응집도는 높다. 그러나, 이러한 단순한 기준은 여러 가지 경우에 클래스의 응집도를 올바르게 구별하지 못한다. 이 논문에서는 기존의 이러한 단순한 기준이 아니라, 멤버들 사이의 연결성 정도에 따라서 응집도를 정의함으로써 문제를 해결하려고 한다.
둘째로, 클래스에는 특수한 목적으로 정의되는 메소드들이 있다. 이들 특별 메소드들은 근본적으로 클래스의 인스턴스 변수들 중에서 일부분 만과의 상호작용으로 충분히 자신의 목적을 달성할 수 있다 기존의 척도들은 이러한 특별 메소드의 특성이 반영되지 않았기 때문에, 실제 응집도보다 낮게 평가하는 문제점을 가진다. 이 논문에서는 이러한 특별 메소드의 특성을 응집도 척도에 반영하였다.
세째로, 클래스에는 다른 인스턴스 변수로부터 그 값이 계산될 수 있는 유도 인스턴스 변수가 존재한다. 만약 메소드가 유도 인스턴스 변수와 상호작용을 한다면, 이 메소드는 유도 인스턴스 변수의 값을 결정하는 인스턴스 변수들, 즉 기저 인스턴스 변수들과도 묵시적인 상호작용을 하는 것이다. 기존의 응집도 척도들은 이러한 유도 인스턴스 변수의 특성이 반영되지 않았기 때문에 정확하게 응집도를 평가할 수 없었다. 이 논문에서는 유도 인스턴스 변수를 파악하고 이들의 특성을 응집도 척도에 반영하였다.
기존의 응집도 척도들에서 발견되는 문제점들을 보완하기 위하여 클래스 자체의 특성을 응집도 척도에 반영함으로써 새로운 척도를 제안하였다. 또한, 이 논문에서는 제안된 응집도 척도를 포함한 기존의 응집도 척도를 C++ 프로그램에 대하여 자동으로 계산하기 위해 개발된 응집도 측정 도구에 대하여 설명하며, 이 도구를 실제 사용하는 C++ 라이브러리인 InterViews에 적용한 사례를 소개한다. 또한, 제안된 척도가 기존의 응집도 척도와는 새로운 측면을 언급하고 있다는 것을 보여 주기 위해서 수행된 주성분 분석의 결과도 소개한다.