Functional Point and Cyclometric complexity
Functional Point and Cyclometric complexity
Allan J. Albrecht initially developed function Point Analysis in 1979 at IBM and it has been
further modified by the International Function Point Users Group (IFPUG). FPA is used to
make estimate of the software project, including its testing in terms of functionality or
function size of the software product. However, functional point analysis may be used for the
test estimation of the product. The functional size of the product is measured in terms of the
function point, which is a standard of measurement to measure the software application.
Objectives of FPA
The basic and primary purpose of the functional point analysis is to measure and provide the
software application functional size to the client, customer, and the stakeholder on their
request. Further, it is used to measure the software project development along with its
maintenance, consistently throughout the project irrespective of the tools and the
technologies.
Following are the points regarding FPs
1. FPs of an application is found out by counting the number and types of functions used in
the applications. Various functions used in an application can be put under five types, as
shown in Table:
Types of FP Attributes
The functional complexities are multiplied with the corresponding weights against each
function, and the values are added up to determine the UFP (Unadjusted Function Point) of
the subsystem.
Here that weighing factor will be simple, average, or complex for a measurement parameter
type.
The Function Point (FP) is thus calculated with the following formula.
FP = Count-total * [0.65 + 0.01 * ∑(fi)]
= Count-total * CAF
where Count-total is obtained from the above Table.
CAF = [0.65 + 0.01 *∑(fi)]
and ∑(fi) is the sum of all 14 questionnaires and show the complexity adjustment value/
factor-CAF (where i ranges from 1 to 14). Usually, a student is provided with the value of
∑(fi)
Also note that ∑(fi) ranges from 0 to 70, i.e.,
In the above control flow graph, there are seven nodes(N) denoted by blue circles. Please
note, the total number of lines in the code is equal to the total number of nodes. There are
eight edges(E) in the control flow graph denoted in red, and since there is only one method,
the total number of connected components(P) in the graph is 1. So as per the formula,
V(G) = E - N + 2 * P
=8-7+2*1=3
In the above code and its control flow graph, there are two conditional statements, IF X =
300, and THEN IF Y > Z, hence there are two conditional nodes(P) namely, 1, and 2,
denoted in green in the control flow graph. So as per the formula,
V(G) = P + 1
=2+1=3
In the above control flow graph, there are two closed regions(R), denoted by two transparent
circles namely 1, and 2 denoted in orange in the control flow graph. So as per the formula,
V(G) = R + 1
=2+1=3
So using the three formulae, we have obtained the same value of cyclomatic complexity as
3.
Uses of Cyclomatic Complexity
The uses of the cyclomatic complexity are listed below −
Detecting all the independent paths prove to be very helpful for both the developers
and testers.
It confirms that every path in the code is verified at least once.
It helps to detect the uncovered paths in the program code.
It assists in improving the code coverage.
It aids in identifying the potential risks and to mitigate them.
Advantages of Cyclomatic Complexity
The advantages of the cyclomatic complexity are listed below −
It is used as a quality metric for the code developed for the software.
It is faster than the Halstead metric.
It helps to determine the effort and critical areas for testing.
It steers the testing process.
It can be applied easily.
Disadvantages of Cyclomatic Complexity
The disadvantages of the cyclomatic complexity are listed below −
It is only concerned with complexity of the software code and not the data it handles.
The cyclomatic complexity value for nested program code is not easily determined.
The cyclomatic complexity may bear false value for simple comparisons and decision
structures.
Example 1
For simple code statements, we can merge them into a single node.
int main() {
int x = 5, y = 10;
x = y + 2;
cout << x << endl;
return 0;
}
Here is the control flow graph and the cyclomatic complexity for the code above.
case "2":
cout << "Tuesday";
case "3":
cout << "Wednesday";
break;
case "4":
cout << "Thursday";
case "5":
cout << "Friday";
break;
default:
cout << "Weekend";
break;
}
return 0;
}
Here is the control flow graph and the cyclomatic complexity for the code above.
Figure 4: Control Flow Graph and Cyclomatic Complexity for Example 4