Cognitive Weighted Response For A Class: A New Metric For Measuring Cognitive Complexity of OO Systems
Cognitive Weighted Response For A Class: A New Metric For Measuring Cognitive Complexity of OO Systems
Cognitive Weighted Response For A Class: A New Metric For Measuring Cognitive Complexity of OO Systems
Abstract –Various new techniques, methods and metrics are being developed by researchers for
calculating the complexity of the class in Object Oriented (OO) software. Chindamber and
Kemerer (CK) have proposed a metric suite for measuring the class complexity of OO design. CK
metrics are well known and widely accepted suites of OO metrics. Among those set of metrics,
Response For a Class (RFC) is one of the metric which is nothing but the number of methods that
can be potentially executed in response to a message received by an object of a class. In RFC, each
function call statement value is considered to be 1. The cognitive feature is not included in RFC
metric which felt major negative aspect of this metric. So here, we are proposing a new metric
namely Cognitive Weighted Response For a Class (CWRFC). In CWRFC, the cognitive weights
have to be assigned for the function call statement based on the effort needed to understand their
type of function calls due to message passed by an object of that class. The proposed metric has
been proved to be a better measure of cognitive complexity of class with function call statement
through the case studies and experiments.
4.1 INTRODUCTION
Since, the complexities of software systems are more famous now than ever the
challenges to a software engineer are to somehow understand and manage such large systems
and deal with software cognitive complexities [9]. Cognitive informatics is a trans-disciplinary
enquiry of cognitive and information sciences that investigates the internal information
processing mechanisms and processes of the brain and natural intelligence, and their engineering
applications via an interdisciplinary approach [42]. Software complexity deals with the
Psychological complexity of the programs [23]. It measures serve both as an analyzer and a
predictor in quantitative software engineering [5]. Identification of complex modules is very
important as they require exact testing so as to develop a better quality software system.
Additionally, this identification may help during maintenance. Source code metrics can be used
to locate such modules. Object-oriented technologies have been increasingly used in
organizations these days. It is theorized that structural properties such as coupling, cohesion,
functional complexity and inheritance have an impact on the cognitive complexity of the system
[11]. That is, it places a “mental burden” on developers, inspectors, testers and maintainers to
understand the system [42].
Software metrics play a vital role in the software industry to assure the quality of the
software. Though the reusability function of Object Oriented Paradigm has enriched the
capability of several software industries, it has considerably increased the complexity [26]. So,
there is a need for introducing new complexity measures. A new metric namely Cognitive
Weighted Response For a Class (CWRFC) is proposed for an OO systems which is an extension
of the Response For a Class (RFC) proposed Chindamber and Kemerer (CK) [8]. CWRFC
includes the cognitive complexity due to message passing by an object to the Function Call
Statement (FCS) and is a better indicator of complexity of OO systems.
Calling the function is an indispensable part of an OO programming language. Function
is called by its name and the message may be passed through the list of arguments. Based on the
message passing, the FCS is divided into two categories such as Default Function Call Statement
(DFCS) and Argumentum Function Call Statement (AFCS). Commonly messages are passed in
two ways. They are Pass By Value (PBV) and Pass By Reference (PBR). It is proven that an
AFCS may be represented as the combination of PBV and PBR. In PBV, values are passed from
actual arguments of a calling function to formal arguments of a called function. In PBR,
addresses are passed from actual arguments of a calling function to formal arguments of a called
function. It is known that, in PBR the changes made in the called function will be reflected in the
calling function, where as in PBV the changes will not be reflected.
With respect to many cognitive processes, the Cognitive complexity of a computer
program can be studied. Program comprehension is one of the important cognitive processes
involved in programming. In this paper, a new metric CWRFC is defined and validated against
the comprehension process.
4.2 LITERATURE REVIEW
Several metrics have been proposed for OO systems by researchers. A metric suite
proposed by Chindamber and Kemerer (C&K) is one of the best known suites of OO metrics.
The six metrics proposed by CK are Weighted Method per Class (WMC), Depth of Inheritance
Tree (DIT), Response For Class (RFC), Number Of Children (NOC), Lack of Cohesion of
Methods (LOCM) and Coupling Between Objects (CBO)[21,8]. Parvinder Singh Sandhu and Dr.
Hardeep Singh [6] have proposed a paper that gives the evaluation of CK suit of metrics and
suggests the refinements and extensions to these metrics so that these metrics should
reflect accurate and precise results for OO based systems. Raed Shatnawi [24] has proposed
a paper that identifies the threshold values for CBO, RFC and WMC at two levels of risks using
a quantitative methodology based on the logistic regression curve. These threshold values can be
used to identify the most error-prone classes.
Classes are the building blocks of any object oriented program. Class is an encapsulation
of attributes and functions (function are known as methods). Functions are the self contained
block of statement that performs some kind of task. It reduces the complexity and debugging of
the larger programming by dividing them into smaller functions. It is clear that the function is
one of the major factors which will affect the complexity of the class and the use of different
type of function call statement will increase the complexity of the programs. There are no
Specific measures that exist to calculate the complexity arising due to cognitive load in
understanding the different FCS. Hence, a new metric [CWRFC] has been proposed for object
oriented system with an internal architecture of an object.
Section organization of this chapter is as follows, the proposed metric CWRFC is
explained in section 4.3, Calibration of FCS is discussed in section 4.4, the experimentation of a
new metric and the case study is described in section 4.5, a comparative study of CWRFC with
RFC in section 4.6 and Section 4.7 presents the conclusion and future work.
Wang et.al, [45] has proposed cognitive weights of the control structure in a method as 1,
2, 3, and 4 to the sequence, branch, iteration and function call statement respectively. J.Charles
et. al [1] has also validated the weights proposed by Wang. Therefore, the cognitive weight of
the Function Call Statement holds the value as 2 by Wang [45].
The weighting factor of different type of the FC statement is based on the classification of
cognitive phenomenon as described by Wang[49], is as follows
Weights
Sub-Conscious Cognitive Function Call Statement (DF) 1
300
250
200
150
Programs
100
50
0
1 2 3 4 5 6 7 8 9
Fig.4.2 The average time of each program from the test conducted on the students.
TABLE 4.1
AVERAGE TIME OF AN EACH PROGRAM AND ITS CATEGORY
Programs Average Time Category Average Time
1 227.4483
2 170.1379 PBR 179.1494
3 139.8621
4 133.4483
5 137.7241 PBV 142.2299
6 155.5172
7 129.1724
8 79.86207 DF 104.9655
9 105.8621
In the Table 4.1, the average comprehension time of programs is listed. These programs
are based on object oriented programs. The mean times are also calculated for each category of
the programs and are tabulated. From the table, it’s clear that, the mean time of PBR is higher
than PBV which in turn is higher than DF. That implies the cognitive load to understand the PBR
is greater than PBV and DF. So here, we conclude that PBR, PBV and DF belong to Higher,
Meta and Sub Cognitive Function Call respectively. The graphical representation of Fig.4.3
gives a better understanding of the complexity of PBR, PBV and DF.
DFC
24%
PBR
43%
PBV
33%
Value of CWRFC
m
CWRFC=∑ RSC j
j=1
Here m=5
CWRFC=RSC 1+ RSC 2+ RSC 3+ RSC 4 + RSC 5
= 1+1+1+6+10
= 19
4.6 COMPARISON WITH OTHER MEASURES
A comparative study has been made with most widely accepted CK metric suite [8] and
found that RFC metrics proposed by CK et.al didn’t provides the total complexity of the class by
considering the cognitive complexity due to message passed by an object to the function call of
that class. This differentiates our metric from the CK metrics. Mishra et.al suggested that one can
calculate the complexity of the class by using cognitive weights of the basic control structure
such as sequence, branch, iteration and call structures. The current CWRFC metric is one step
ahead of CK’s RFC, because it includes the complexity that arises due to the different types of
function call statement and internal architecture of an object which passes the message to the
functions. Another advantage of our metric is that, it takes cognitive weights into consideration.
In the following Table 4.2, a comparison has been demonstrated with RFC and CWRFC.
We calculated the weight of the class by calculating the response set complexity, in terms
of Default Function Call Complexity (DFCC) and Argumentum Function Call Complexity
(AFCC). This is better indicator than the CK’s RFC. The weight of each function call statement
is calculated by using cognitive weights and weighting factor of type of the message passed to
the function call statement by an object which is suggested by Chidamber et al and Wang. We
found that the resulting value of CWRFC is higher than the RFC. This is because, in RFC, the
weight of each calling statement is assumed to be one. However, including cognitive weights for
calculation of the RSC is more realistic because it provides for the complexity of the internal
architecture of an object. The results are shown in the Table 3 itself.
TABLE 4.2
RFC CWRFC
Programs
1 9 19
2 10 29
3 5 17
The RFC and CWRFC values were compared and found that CWRFC measure was
larger. According to Chindamber et.al, RFC is an enhanced indicator of complexity of the class.
From the table 3, it is observed that CWRFC value is larger than RFC value which concludes
that CWRFC is a better indicator of complexity of the classes with function call statement
because of the consideration of response set complexity.