Page 54 - Data Science Algorithms in a Week
P. 54
38 Edwin Cortes, Luis Rabelo and Gene Lee
Table 2: Cognitive Weights
Category Basic Control Structure Weight
Sequence Sequemce 1
Branch If-Then-Else 2
Case 3
Iteration For Loop 3
Repeat-untill 3
While-do 3
Embedded Component Function Call 3
Recursion
Concurrency Parallel 4
Interrupt 4
The total cognitive weight of a piece of software c is computed by applying the
following equation 11 and considering several nesting structures j, k, and i:
= ∑ [∏ ∑ ( , , )] ……………… (11)
=1
=1
=1
Cognitive weight scores for a particular block of software contributes more to total
weigh if multiple basic control structures are encompassed within nested sections. For
example, methodA() in Figure 8 achieves a larger cognitive weight than methodB() due
to nested while-loop inside the if-then construct.
Figure 8: Cognitive Weights Sample Calculations.