You are on page 1of 10

The CK Metrics Suite

Weighted Methods Per Class

To use this metric, the software engineer must repeat this process n times, where n is the number of methods for the given class. In order to complete this process, the software engineer must do the following, Compute the complexity of the method, using a specific complexity measure. Please see links for more information on complexity metrics.

Input the value into the text box.


Click the Add button. Continue process until all methods have been completed.

Depth of Inheritance Tree

In order to calculate this metric, the Software Engineer must consult their Inheritance tree.
An Example of this is as follows,

To find this, the Software Engineer must traverse the tree until the deepest child has been visited. It is then this number that should be entered. In the preceding example, the number to be entered into the cell would be 4.

Number of Children
In order to calculate this metric, the Software Engineer must consult their Inheritance Tree. An Example of this is as follows, To calculate this metric, the Software Engineer must calculate the number of children that are one level below the class under calculation. In the preceding example, the number of children for C2 is 3 (C21, C22, C23).

Coupling between Object Classes

In order to find the coupling between object classes, the Software Engineer must consult his/her set of CRC cards.

To find this value, the Software Engineer must do the following,


Obtain the class under calculation CRC index card. Count the number of collaborations listed for the class. Input this number into the cell.

Response for a Class

In order to calculate responce for a class, the Software Engineer must do the following,

Consult the classes CRC index card.


Take the first message and count the number of methods that can potentially be executed in response to this message Record this number, and repeat this process for all methods. When finished, input the greatest number into the cell.

Lack of Cohesion in Methods

In order to calculate the lack of Cohesion in methods, the Software Engineer must consult their CRC index cards. They should then do the following,
Pick the first attribute. Go through the list of CRC cards and count the number of cards that access that particular attribute picked in step one.

Record this number and repeat until all attributes have been processed.
Take the greatest number and input this number into the cell.

Example of CK Metrics
For the first box enter

0.76 , 0.76, 0.79 the hit

ok after each one. For the remaining boxes enter 5


Formula for calculations

WMC = S Ci Weighted Metrics Class = Sum Classes

CK Metrics Summary
Weighted Methods Per Class (WMC): 0.77 Depth of Inheritance Tree (DIT): 5 Number of Children (NOC): 5 Coupling between Object Classes (CBO): 5

Response for a Class (RFC): 5


Lack of Cohesion in Methods (LCOM): 5

CK Metrics Suggestions

1. Your Weighted Methods Per Class Metric is high thus limiting the potential reuse of this class. Therefore, you may want to reduce the number of methods and/or their complexity

2. The Depth of Inheritance Tree is high thus increasing the design complexity.
Therefore, you may want to reduce the use of Inheritance. 3. The Number of Children for this class is high thus diluting the abstraction of the parent class and increasing the amounf of testing. Therefore, you may want to reduce the number of children. 4. The Coupling between object classes is high thus reducing the reusability of a class and complicating modifications and testing Therefore, you may want to reduce the number of collaborator class by combining similar collaborators. 5. The Response for a class is high thus increasing the testing effort, test sequence and the overall design complexity of the class Therefore, you may want to reduce the number of operations that maybe execute in response to a message recieved 6. The Lack of Cohesion in Methods is high thus increasing the complexity of class design Therefore, you may want to reduce the lack of cohesion in methods by breaking down the class into two or more seperate classes.

You might also like