#7 Software Metrics
#7 Software Metrics
You
have been assigned the task of assessing the quality and complexity of the project using object-
oriented metrics. In this context, answer the following questions:
a. Choose three object-oriented metrics and discuss their purpose and relevance in
evaluating software quality.
b. For each of the selected metrics, describe the measurement technique or formula used to
calculate the metric.
Answer:
Object-Oriented Metrics:
a. Coupling:
Purpose and Relevance:
Measurement Technique:
There are different types of coupling, and one common measure is called "Coupling
Between Objects" (CBO). CBO counts the number of classes to which a class is
coupled. The formula for CBO is as follows:
CBO=Number of other classes coupled to a class
Low values of CBO indicate a loosely coupled design, while high values suggest a more
tightly coupled structure.
b. Cohesion:
Purpose and Relevance:
Cohesion assesses how closely the methods within a class are related to each other. A
highly cohesive class has methods that work together to achieve a single, well-defined
purpose. High cohesion is desirable as it promotes better maintainability, reusability,
and understandability of the code.
Measurement Technique:
One common cohesion metric is the "Lack of Cohesion in Methods" (LCOM). LCOM
measures the number of method pairs in a class that do not share instance variables.
The formula for LCOM is given by:
Low LCOM values suggest high cohesion, while high values indicate low cohesion.
c. Cyclomatic Complexity:
Purpose and Relevance:
Measurement Technique:
V=E−N+2P
Where: