The CK Metrics Suite Weighted Methods Per Class

  • Slides: 10
Download presentation
The CK Metrics Suite

The CK Metrics Suite

Weighted Methods Per Class b To use this metric, the software engineer must repeat

Weighted Methods Per Class b 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 b In order to calculate this metric, the Software Engineer

Depth of Inheritance Tree b In order to calculate this metric, the Software Engineer must consult their Inheritance tree. b An Example of this is as follows, b 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. b In the preceding example, the number to be entered into the cell would be 4.

Number of Children b In order to calculate this metric, the Software Engineer must

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

Coupling between Object Classes b In order to find the coupling between object classes,

Coupling between Object Classes b In order to find the coupling between object classes, the Software Engineer must consult his/her set of CRC cards. b 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 b In order to calculate responce for a class, the

Response for a Class b 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 b In order to calculate the lack of Cohesion

Lack of Cohesion in Methods b 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 b For the first box enter 0. 76 , 0.

Example of CK Metrics b For the first box enter 0. 76 , 0. 76, 0. 79 the hit ok after each one. b For the remaining boxes enter 5 b Formula for calculations WMC = S Ci b Weighted Metrics Class = Sum Classes b

CK Metrics Summary b Weighted Methods Per Class (WMC): 0. 77 b Depth of

CK Metrics Summary b Weighted Methods Per Class (WMC): 0. 77 b Depth of Inheritance Tree (DIT): 5 b Number of Children (NOC): 5 b Coupling between Object Classes (CBO): 5 b Response for a Class (RFC): 5 b Lack of Cohesion in Methods (LCOM): 5

CK Metrics Suggestions b 1. Your Weighted Methods Per Class Metric is high thus

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