10
The CK Metrics Suite The CK Metrics Suite

The CK Metrics Suite. Weighted Methods Per Class b To use this metric, the software engineer must repeat this process n times, where n is the number of

Embed Size (px)

Citation preview

Page 1: The CK Metrics Suite. Weighted Methods Per Class b To use this metric, the software engineer must repeat this process n times, where n is the number of

The CK Metrics SuiteThe CK Metrics Suite

Page 2: The CK Metrics Suite. Weighted Methods Per Class b To use this metric, the software engineer must repeat this process n times, where n is the number of

Weighted Methods Per Weighted Methods Per ClassClass

To use this metric, the software engineer must repeat To use this metric, the software engineer must repeat this process n times, where n is the number of methods this process n times, where n is the number of methods for the given class. In order to complete this process, the for the given class. In order to complete this process, the software engineer must do the following, software engineer must do the following,

– Compute the complexity of the method, using a Compute the complexity of the method, using a specific complexity measure. Please see links specific complexity measure. Please see links for more information on complexity metrics. for more information on complexity metrics.

– Input the value into the text box. Input the value into the text box.

– Click the Add button. Click the Add button.

– Continue process until all methods have been Continue process until all methods have been completed. completed.

Page 3: The CK Metrics Suite. Weighted Methods Per Class b To use this metric, the software engineer must repeat this process n times, where n is the number of

Depth of Inheritance TreeDepth of Inheritance Tree

In order to calculate this metric, the Software Engineer must In order to calculate this metric, the Software Engineer must consult their Inheritance tree. consult their Inheritance tree.

An Example of this is as follows, An Example of this is as follows,

To find this, the Software Engineer must traverse the tree until the To find this, the Software Engineer must traverse the tree until the deepest child has been visited. It is then this number that should deepest child has been visited. It is then this number that should be entered. be entered.

In the preceding example, the number to be entered into the cell In the preceding example, the number to be entered into the cell would be 4.would be 4.

Page 4: The CK Metrics Suite. Weighted Methods Per Class b To use this metric, the software engineer must repeat this process n times, where n is the number of

Number of ChildrenNumber of Children

In order to calculate this metric, In order to calculate this metric, the Software Engineer must the Software Engineer must consult their Inheritance Tree. consult their Inheritance Tree.

An Example of this is as follows, An Example of this is as follows,

To calculate this metric, the To calculate this metric, the Software Engineer must calculate Software Engineer must calculate the number of children that are the number of children that are one level below the class under one level below the class under calculation. calculation.

In the preceding example, the In the preceding example, the number of children for C2 is 3 number of children for C2 is 3 (C21, C22, C23).(C21, C22, C23).

Page 5: The CK Metrics Suite. Weighted Methods Per Class b To use this metric, the software engineer must repeat this process n times, where n is the number of

Coupling between Coupling between Object ClassesObject Classes In order to find the coupling between object In order to find the coupling between object

classes, the Software Engineer must consult classes, the Software Engineer must consult his/her set of CRC cards. his/her set of CRC cards.

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

– Obtain the class under calculation CRC Obtain the class under calculation CRC index card. index card.

– Count the number of collaborations Count the number of collaborations listed for the class. listed for the class.

– Input this number into the cell. Input this number into the cell.

Page 6: The CK Metrics Suite. Weighted Methods Per Class b To use this metric, the software engineer must repeat this process n times, where n is the number of

Response for a ClassResponse for a Class

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

– Consult the classes CRC index card. Consult the classes CRC index card.

– Take the first message and count the Take the first message and count the number of methods that can potentially number of methods that can potentially be executed in response to this message be executed in response to this message

– Record this number, and repeat this Record this number, and repeat this process for all methods. process for all methods.

– When finished, input the greatest When finished, input the greatest number into the cell. number into the cell.

Page 7: The CK Metrics Suite. Weighted Methods Per Class b To use this metric, the software engineer must repeat this process n times, where n is the number of

Lack of Cohesion in Lack of Cohesion in MethodsMethods

In order to calculate the lack of Cohesion in In order to calculate the lack of Cohesion in methods, the Software Engineer must consult their methods, the Software Engineer must consult their CRC index cards. They should then do the CRC index cards. They should then do the following, following,

– Pick the first attribute. Pick the first attribute.

– Go through the list of CRC cards and count Go through the list of CRC cards and count the number of cards that access that the number of cards that access that particular attribute picked in step one. particular attribute picked in step one.

– Record this number and repeat until all Record this number and repeat until all attributes have been processed. attributes have been processed.

– Take the greatest number and input this Take the greatest number and input this number into the cell.number into the cell.

Page 8: The CK Metrics Suite. Weighted Methods Per Class b To use this metric, the software engineer must repeat this process n times, where n is the number of

Example of CK MetricsExample of CK Metrics

For the first box enter 0.76 , 0.76, For the first box enter 0.76 , 0.76, 0.79 the hit ok after each one.0.79 the hit ok after each one.

For the remaining boxes enter 5For the remaining boxes enter 5

Formula for calculationsFormula for calculations WMC = WMC = CCii

Weighted Metrics Class = Sum ClassesWeighted Metrics Class = Sum Classes

Page 9: The CK Metrics Suite. Weighted Methods Per Class b To use this metric, the software engineer must repeat this process n times, where n is the number of

CK Metrics SummaryCK 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

Page 10: The CK Metrics Suite. Weighted Methods Per Class b To use this metric, the software engineer must repeat this process n times, where n is the number of

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.