comp589 (1)
TRANSCRIPT
Applicability of Three Cognitive Complexity MetricsArvin ForoutanStan Pastukhov
Software Complexity
Can be the execution time required to perform a computation
Or maybe the level of difficulty of tasks such as coding, debugging, testing or modifying software
Cognitive Complexity
The human effort needed to perform a task
Or the difficulty in understanding the software
Why is this important?
Unlike new software development, maintaining and expanding existing code is extremely difficult
Prone to cost overruns, delays, and defects
Cognitive Weight
The degree of difficulty or relative time and effort for comprehending a given piece of software
Modeled by a number of basic control structures (BCS)
Sequential, Branch, Iteration, Recursion and Parallel
The Big 3: Which is best?
Cognitive Weight Complexity Measure (CWCM)
Cognitive Functional Size (CFS)
Cognitive Information Complexity Measure (CICM)
Cognitive Weight Complexity Measure (CWCM)
Considers only the cognitive weights (Wc) of the basic control structures of the software
Language independentSimple and easy to calculateGives the complexity in small numbers
Bubble Sort - CWCM Metric CWCM = Wc
Where:
Wc = Total cognitive weight of software
BCS (iteration) W1 = 3
BCS (iteration) W2 = 3
BCS (branch) W3 = 2
BCS (branch) W4= 2
Wc = 3(3(2)) + 2) = 24
Cognitive Functional Size (CFS)
Based on cognitive weights of basic control structures and number of inputs and outputs
Easy to calculateDoes not rely on the implementation technologies
Uses sound principles
Bubble Sort - CFS metric
CFS = (No + Ni) * Wc
Where:
No = Number of outputs
Ni = Number of inputs
Wc = Sum of cognitive weights of linear blocks
CFS = (0 + 1) * 24 = 24
Cognitive Information Complexity Metric (CICM)Calculated by getting the product of cognitive weight (Wc) of the basic control structures and the weighted information count (WICS)
Dependent on the internal architecture of the software
Slightly more difficult to calculateGives complexity in larger numbers
Bubble Sort - CICM Metric CICM = WICS * Wc
Where:
WlCS = Sum of weighted information count of all the lines in the software
Wc = Total cognitive weight of software
WlCS = 2/19 + 2/18 + 2/17 + 1/16 + 7/15 + 1/14 + 8/13 + 5/12 + 3/11+ 5/10 + 4/9 + 1/8 + 0 + 0 + 2/5 + 0 + 0 + 0 + 0 + 0
WlCS = 3.71 Wc = 24
CICM = 3.71 * 24 = 89.04
Objective
To study the relationship between the three cognitive complexity metrics and to find out which is the best metric to be used in the real world
What did they measure?
Ten different programs were testedAll written in JavaNone were similar to each other
Programs To Be MeasuredBlink.javaBubbleSort.javaClass2.javaCoalescedChainingApp.javaCollisionExperiment.javaFactMain.javaFibonacciMain.javaJumpingBox.javaLauncherThread.javaListStack.java
SurveyTo get an expert opinion of the complexities of each program:
30 software developers with 5+ years experience from five leading IT organizations in Sri Lanka
Each ranked the programs on a scale between 1-10
1 being the least complex10 being the most complexAll other programs fall in between
CFS Values For The 10 Programs Program CFS
Blink.java 22
Bubblesort.java 84
Class2.java 10
CoalescedChainingApp.java 171
CollisionExperiment.java 92
FactMain.java 12
FibonacciMain.java 18
JumpingBox 270
LauncherThread.java 24
ListStack.java 75
CWCM Values For The 10 Programs Program CWCM
Blink.java 22
Bubblesort.java 69
Class2.java 10
CoalescedChainingApp.java 57
CollisionExperiment.java 23
FactMain.java 12
FibonacciMain.java 18
JumpingBox 45
LauncherThread.java 6
ListStack.java 25
CICM Values For The 10 Programs Program CICM
Blink.java 122.54
Bubblesort.java 311.88
Class2.java 36.41
CoalescedChainingApp.java 326.61
CollisionExperiment.java 115.46
FactMain.java 42.24
FibonacciMain.java 73.62
JumpingBox 170.55
LauncherThread.java 32.22
ListStack.java 43.5
ConclusionCWCM had the lowest correlation (0.503)CICM had the second lowest correlation (0.588)CFS had the highest correlation (0.903)
Based off these results, CFS is the most suitable cognitive complexity metric to be used in the real world
The End
Questions, comments, suggestions?