0% found this document useful (0 votes)
42 views

#7 Software Metrics

The document discusses three important object-oriented metrics for evaluating software quality: coupling, cohesion, and cyclomatic complexity. Coupling measures interdependence between classes and is assessed using Coupling Between Objects (CBO). Cohesion evaluates relatedness of methods within a class and is measured using Lack of Cohesion in Methods (LCOM). Cyclomatic complexity quantifies a program's complexity based on its control flow graph. These metrics provide insights into a project's design, complexity, and maintainability when applied systematically.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

#7 Software Metrics

The document discusses three important object-oriented metrics for evaluating software quality: coupling, cohesion, and cyclomatic complexity. Coupling measures interdependence between classes and is assessed using Coupling Between Objects (CBO). Cohesion evaluates relatedness of methods within a class and is measured using Lack of Cohesion in Methods (LCOM). Cyclomatic complexity quantifies a program's complexity based on its control flow graph. These metrics provide insights into a project's design, complexity, and maintainability when applied systematically.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

7. Consider a software project developed using an object-oriented programming language.

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 programming (OOP) stands as a cornerstone in contemporary software


development practices, serving as a paradigm that facilitates modular and scalable
code. The success of a software project hinges upon the adept assessment of its
quality and complexity. To achieve this, object-oriented metrics come into play, offering
a set of quantitative measures instrumental in gauging the efficacy of a project's design
and implementation. In the subsequent exploration, three pivotal object-oriented metrics
—coupling, cohesion, and cyclomatic complexity—take center stage. Coupling
delineates the interdependence between classes, a metric crucial in unveiling the
modularity of the code. Cohesion, on the other hand, scrutinizes the relationships
between methods within a class, emphasizing the importance of a unified purpose for
enhanced maintainability. Cyclomatic complexity steps in as a metric quantifying the
intricacy of the program, scrutinizing the paths through the code. These metrics
collectively contribute to the holistic evaluation of software quality and complexity,
enabling developers to make informed decisions regarding design modifications, code
maintainability, and overall project success. The comprehensive understanding and
application of these metrics empower software engineers to craft systems that not only
adhere to best practices but also stand resilient in the face of evolving project
requirements and industry standards.

Object-Oriented Metrics:

a. Coupling:
Purpose and Relevance:

Coupling measures the degree of interdependence between modules or classes within a


software system. Low coupling is desirable as it indicates a modular and maintainable
design. High coupling can lead to increased complexity, making the software harder to
understand, modify, and maintain.

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:

LCOM=Number of method pairs not sharing instance variables

Low LCOM values suggest high cohesion, while high values indicate low cohesion.

c. Cyclomatic Complexity:
Purpose and Relevance:

Cyclomatic complexity is a metric that quantifies the complexity of a program by


measuring the number of linearly independent paths through its source code. A lower
cyclomatic complexity is preferred as it indicates a more straightforward and less error-
prone design.

Measurement Technique:

The formula for cyclomatic complexity (V) is given by:

V=E−N+2P

Where:

● E is the number of edges in the control flow graph.


● N is the number of nodes in the control flow graph.
● P is the number of connected components (for a single program,
The resulting V value helps in assessing the project's complexity; higher values suggest
a more complex code structure.

In conclusion, the meticulous evaluation of software quality and complexity plays an


indispensable role in fostering successful project development, a principle underscored
by our university's guidelines. Object-oriented metrics, including coupling, cohesion, and
cyclomatic complexity, emerge as indispensable tools offering profound insights into
the intricacies of software design and implementation. Within the framework set by our
university, these metrics become crucial decision-making instruments, guiding
developers towards actions that elevate maintainability, promote reusability, and
ultimately contribute to an overarching improvement in software quality. Adhering to our
university's standards, the incorporation of these metrics becomes not just a best
practice but a requisite step in the pursuit of robust, efficient, and high-quality software
systems.

You might also like