CodePlex: Software Complexity Measuring Tool based on ECB Measure

The surge in popularity of object-oriented programming as a predominant paradigm in software development has spurred numerous studies to introduce metrics for assessing the complexity of object-oriented programs. These metrics typically fall into two primary categories: those focusing on object-oriented aspects and those centered on cognitive aspects, delineating their principal areas of concern when evaluating program complexity. Within the realm of cognitive aspects, the majority of metrics have historically been confined to the consideration of no more than three complexity variables. However, the ECB (Enhanced Cognitive Based) measure stands as a notable exception, capable of encompassing and addressing four or more intricate facets in the assessment of software program intricacy and difficulty. This research paper undertakes the exploration of the incorporation of these multidimensional metrics as refinements to the existing weighted composite complexity CB measure, originally introduced by Chhillar and Bhasin. In doing so, it endeavors to furnish a more comprehensive and holistic framework for the evaluation of program complexity, accommodating both object-oriented and cognitive dimensions. Furthermore, the study assumes the pivotal role of empirically validating the practical effectiveness of the ECB measure, seeking to bridge the chasm between theoretical metrics and their tangible applicability in real-world settings. Such an endeavor holds profound significance for software developers and researchers, proffering invaluable insights that can advance our understanding and management of intricate object-oriented programs.


INTRODUCTION
The literal meaning of complexity is referred to as a state of difficulty having parts of understanding or comprehending something.[1] In the context of software, complexity pertains to the intricacy that hinders the clear understanding of various aspects of the software process.
It is the degree to which challenges are faced when verifying and understanding software systems and their components from the design phase to the implementation and maintenance phase [2].Software complexity is not a new concept.Many researchers have been interested in this subject since the 1970s [3] [4].Due to that, it was evident that the importance of having metrics to measure the software complexity is necessary.Over time, a multitude of metrics for measuring software complexity have been introduced.[3] [4] [5] [6] [7] [8] [9] Also, several classifications of these metrics were identified to understand the scope.Notably, a seminal classification was presented by Halstead [3].
 Product Metric -Metrics to describe and quantify qualities of the software product such as size, complexity, design features, performance, and quality level. Process Metric -Metrics to improve software development and maintenance such as identification and removal of defects during development, defect testing patterns, and time taken to respond to defects. Project Metric-Metric to explain qualities of the project such as the number of software programmers, life cycle over the software, cost, and productivity.Though there are several metrics introduced, certain problems still arise related to this context.One is the ambiguousness and inconsistency of these metrics.[10] Though the metrics are well-defined and proven with evidence it was found out that most metrics cannot be applicable to each software program.Also due to the improved large diversity of programming languages and concepts these metrics which might have been useful before are no longer applicable.
The second one is the difficulty in correctly identifying the most suitable metric among many of the metrics.Due to the very same reason mentioned above it was hard to select the best and most appropriate metric to measure the software complexity and comprehend actual meaning and the benefit behind the measurements.Another problem is to identify which quality should be taken into consideration when measuring software complexity.As a solution for this Wyuker has introduced 6 different properties that software complexity metrics should satisfy [11].According to her observation, both Halstead's metrics [3] and Cyclomatic complexity [4] which are considered a few of the most accepted complexity metrics worldwide fail to satisfy all these properties.
With the Object Oriented (OO) concepts came into light another problem was raised, which is the scarcity of metrics that measure programs with OO concepts.Even though there are metrics that already considered this subject, most of these metrics only measure a few attributes and elements regarding OO concepts.This denotes that a single metric will not be enough to measure all the qualities of object-oriented program design.The purpose of this research is to introduce a software metric specifically for software programs which will cover multiple aspects of Object-Oriented design.This metric aims to address the abovementioned challenges.
On average around 80% -90% of the annual cost of the software life cycle would be spent on the software maintenance phase [12].There is a fundamental relationship between software complexity and software maintenance.With the proper application of software complexity metric, this huge expenditure on maintenance can be greatly reduced.With the help of complexity measures a proper understanding of the quality and the reliability of software could be enhanced and the proper controls on complexity will enhance many operations related to maintenance.[6] [8] [2] [13].
One of the metrics that is concerned with several features of Object-oriented concepts at a time is Chhillar and Bhasin's Cognitive Based (CB) Measure named Weighted Composite Complexity (WCC) Measure [8].This metric will quantify four factors of a program which are inheritance, control structure, nesting level, and the size of the program.In this metric specific weight would be allocated for the above factors.The objective of this research will be to introduce and develop a tool named "Codeplex" based on this WCC alongside improvements for this.As it suggests enhancing the measure it will be named after Enhanced Cognitive Based (ECB) Measure.
In summary, this paper will discuss the importance of software complexity and software metrics as well as the interrelationship between these metrics and the maintenance of software as it will suggest a new method as well as develop a tool based on ECB to calculate, analyze code, and support decision-making related to software development phase in the hope of improving the maintainability and reliability of a software product.

II. LITERATURE REVIEW
The very first attempt to identify the complexity of code was Wolverton in 1974 by introducing Line of Code (LOC) which measures the production ratio of programmers [13].In 1976, McCabe introduced cyclomatic complexity which is a mathematical technique to identify software complexity based on control flows in software modules [4].He introduced a unique name, a cyclomatic number that represents a maximum number of linear paths in the control flow in terms of cognitive weights.These cognitive weights are measured based on the extent to which the software program is difficult to comprehend.
In 1977 Halstead introduced another set of metrics which was also improving LOC [3].Halstead's metrics are used to estimate the size, complexity, and effort requirement of the software.However, it was later found out that these metrics have limited scope, limited applicability, and limited accuracy with the increase of the complexity of a program.[14].These metrics will be based on the number of operators and operands in the program.
In 1981, Henry Kafura introduced a complexity measure named fan-in-fan-out where fan-in is the number of information flowing into a program module and fanout is the number of information flowing out of a program module.
In 1994, Chdamber and Kamerer [5] introduced a new suite of metrics that is very famous for measuring the complexity of object-oriented design.This includes 6 different metrics namely: • Weighted Methods per Class (WMC) (LORM).In 2005 Costagliola and Tortura [7] introduced a functional point-like approach named class point which also supports estimating the size of Object-oriented products.
In 2007 Misra and Sanjay [2] introduced complexity metrics which is specifically focused on class in the method level which is an attempt to identify and evaluate methods of Object-oriented design by considering the internal architecture of the class.
In 2011, Chhillar and Bhasin introduced the WCC measure and in 2015, Arbi and Gahazarian [10] introduced a universal complexity theory called Informational Volumetric Complexity (IVC).

III. PROPOSED ENHANCED COGNITIVE BASED COMPLEXITY MEASURE
According to Chhillar and Bhasin's WCC measure, different cognitive-based weights are allocated for four different factors.The weight allocation of WCC is as follows: Inheritance Level (W i ): The deeper the inheritance is, the harder it is to understand.Therefore, it affects complexity.For the WCC measure, difference weights will be allocated considering the class level.For example, Base Class: In the case of a base class, it is assigned a weight of 0, indicating the lowest complexity level.First Derived Class from Base Class: When a class is in first level of derivation from the base class, it is given a weight of 1, signifying a moderate level of complexity Second Derived Class: For a class that is two levels deep in the inheritance hierarchy, it is allocated a weight of 2, indicating a higher level of complexity.

Types of Control Structures (W c ):
A program with diverse control structures is difficult to comprehend and different control structures contribute complexity in different ways.In WCC measures weights will be allocated considering the type of control structure.Sequential statements, which represent a linear flow of code execution, are assigned a weight of 0. Conditional statements, which introduce decision-making logic into the code, are allocated a weight of 1. Iterative statements, responsible for creating loops and repetitive execution, receive a weight of 2. Switch Cases with n Statements (W c ): For switch cases with 'n' individual statements inside, the weight is directly set to 'n.'

Nesting of Control Structures (W n ):
A program with more levels of nesting in the control structure is difficult to comprehend, thus it will also affect the program's complexity.Sequential statements are assigned a weight of 0. Control structures and statements at the outermost level of nesting are assigned a weight of 1.
Control structures and statements at the innermost levels of nesting are assigned a weight of 2.

Size (S j ):
Since the start of this software complexity came to be size is also considered one of the parameters of software complexity.A class with more methods, operators, and operands are way more difficult to understand than a simple program with few statements.Therefore, size is obviously a factor that affects the complexity.In terms of WCC total number of tokens (operators, operands, strings, and methods/functions) will be considered as the weight for the size factor.By considering the above factors following WCC measure introduces the following formula to calculate total weight of the program.
( ) ∑( ) ( ) 1 Cw (P) = Total weight for the program Pn = Total number of executable statements in program P, Wt = Total weight of j th executable statement in program P, Wt = Wn + Wi + Wc Except for the above 4 factors, another four factors will be considered in the introduced ECB measures.They will be as follows.
Multiple Inheritance: Class with multiple inheritance will be difficult to comprehend thus contributing to the complexity of the program.This was not considered when measuring the complexity in the WCC metric.In this ECB, additional weight will be allocated for classes with multiple inheritance.For each class that is derived from more than one class weight of one will be allocated to W i .Compound Conditional Statements: When it comes to conditional statements, there are two types namely simple and compound conditions.In the WCC metric, this point was not considered.In ECB, additional weight will be allocated for conditions with compound conditional statements.For each compound conditional statement, an additional one unit of weight will be allocated for W c .
Methods with Multiple Statements: When it comes to measuring the size of the methods WCC does not measure the difference between two methods which have a considerable number of statements than the other.A function with a greater number of statements with complicated steps would be more difficult to comprehend than the simple method with few steps.Therefore, by considering the number of statements in each method different weights will be allocated in ECB measure.For a function with more than 5 statements, an additional 1 unit of weight will be allocated.For an example method with 5 statements will be given 1 point.The method with 10 statements will be given 2 points.Likewise, additional tokens will be added to S j.
Array and Object Declaration: WCC has also not commented on anything on array and object declaration as well.Though it might be less complex compared with other factors it also poses a complexity to the program to a certain extent.In ECB measure, this will be also considered when measuring the complexity.An array declaration will be considered as normal variable declaration and due to the uniqueness of an array data structure additional points will be allocated for the S j .The object declaration will also be considered the same as a normal variable declaration which was also not mentioned in WCC.

IV. EXPERIMENTAL RESULTS AND DISCUSSION
The main objective of this paper is to identify the places that can be improved within the CB measure dons in WCC.As mentioned in the Section III authors have identified 4 different factors that can be improved in WCC.Those are multiple inheritance, array and object declaration, compound conditional statements and functions with multiple statements.The weights will be allocated according to the methodology and a calculation has been done separately for each WCC and ECB.Table 1, Table 3, Table 5, Table 7 are examples measured according to the WCC, and Table 2, Table 4 Table 6, and Table 8 are examples measured according to the ECB.According to the above-mentioned methodology, weights will be allocated for considering the inheritance level of the program.Additionally, on ECB multiple inheritance will be considered when measuring the complexity.Assigning a weight of one to control structure attributes (W c ) whenever the "&&" or "||" operator is used.The impact of compound situations on programming intricacy is shown through an example of C++ code presented in Figure 2. The program's careful design highlights the complexities of measuring simplicity when distinct control systems are implemented.Through Tables 3 and Table 4, the subsequent examination presents a detailed and straightforward depiction of how software complexity is measured for the code displayed in Figure 2.

WCC CB Value 35
But here notice that in Table 6, line 21 and 22, an array and object declaration can be found.In WCC this aspect was not considered.But authors found those can be attributed to increasing the code complexity.Therefore, additional points are allocated in S j in Table 6.

WCC CB Value 38
When considering the Methods with Multiple Statements feature, the ECB software complexity measure produces intriguing outcomes.Within methods, different statement counts lead to cognitive disparities that WCC does not identify.The introduction of weighting according to statement count increases ECB calculation.Methods featuring abundant statements, complex control flow, logical conditionals, and multiple operations tend to receive better ECB ratings.But here notice that in Table 7 line 20, class Complexity Calculator is an example with multiple statements.In WCC this aspect was not considered and allocated the same weights for both methods with one and multiple statements inside.But authors found that methods with multiple statements might be more complex and allocated more weight for that.The allocation is done as one more weight.Instead of just creating another generic metric calculator, our aim was to pioneer a revolutionary approach that addresses the endemic problems in software engineering.With the ECB measure, we offer a potent tool that enables professionals to improve the quality and efficiency of their software development projects, streamline their coding procedures, and make informed judgments.
Depth of Inheritance Tree (DIT) • Number of children (NOC) • Coupling between object classes (CBO) • Response for a Class (RFC) • Lack of Cohesion in Methods (LCOM) In 1997, Another metric by T.Mayer and T.Hall introduced an improved version of the MOOD metric.It covers the following factors namely: • Method Hiding Factor (MHF) • Attribute Hiding Factor (AHF) • Method Inheritance Factor (MIF) • Attribute Inheritance Factor (AIF) • Polymorphism Factor (PF) • Coupling Factor (CF) In 2000, Etzkom and Delugach [15] introduced another tool for object-oriented design where complexity measures are done for the factors such as the class cohesion, class interface complexity, class overlap.The metric was named Logical Relatedness of Methods This work is licensed under Creative Commons Attribution 4.0 International License.

Figure 1 :
Figure 1: Sample program to demonstrate the effect of Inheritance

Figure 2 :
Figure 2: Sample program to demonstrate the effect of compound conditions

8 51
array, and object declarations in a program bring out.To assess software complexity, it is crucial to comprehend how these declarations impact program structure and behavior.This problem is addressed and a nuanced understanding of program complexity in realistic software development contexts is provided by the suggested ECB measure.International Journal of Engineering and Management Research Peer Reviewed & Refereed Journal e-ISSN: 2250-0758 | p-ISSN: 2394-6962 Volume-13, Issue-5 (October 2023) https://ijemr.vandanapublications.com https://doi.org/10.31033/ijemr.13.5.This work is licensed under Creative Commons Attribution 4.0 International License.

Figure 4 :
Figure 4: Sample program to demonstrate the effect of Methods with Multiple Statements

Table 1 :
CB for Result Program for multiple inheritance

Table 2 :
ECB for Result Program for multiple inheritance

Table 3 :
CB for Result Program for compound conditional statements

Table 4 :
ECB for Result Program for compound conditional statements

Table 6 :
ECB for Result Program for object and array declaration

Table 7 :
CB for Result Program for methods with multiple statements

Table 8 :
ECB for Result Program for methods with multiple statements In conclusion, our research has resulted in the development of the Enhanced Cognitive Based (ECB) measure, a tool made to satisfy the requirements of developers and technical leads.A more advanced and enhanced version of the conventional Weighted Code Complexity (WCC) metric is represented by ECB.It is a useful asset since it provides increased explanatory power.Compared to traditional code complexity measures, ECB provides a higher level of accuracy and dependability based on object, array declarations, multiple inheritance, compound conditional statements, methods and multiple statements.