An Experiment to Measure the Cognitive Weights of Code Control Structures

David Adamo Jr.

Tools and Acknowledgements

Problem and Experiment

Commonly used software complexity measures do not consider code comprehension

Cognitive complexity measures have been proposed to handle this

Web app presents users with code snippets and tracks response times

14 participants (computer science grad students), 22 code snippets, 3 snippets for each control structure

Web App - CodeScale

Sequence Response Times

Normalize for length of snippets  

  • major issue in previous experiments

Equations and Definitions

t(C_i) = \sum_{j=1}^{n_{attempts}} t(att_j) + t(att_{correct})
t(Ci)=j=1nattemptst(attj)+t(attcorrect)

Participant response time for code snippet i.

Normalized response time for code snippet across all participants

Cognitive weight of a particular control structure

Control Structure Response Times

Cognitive Weight Values

Comparison with Previous Work

[1] J. Shao and Y. Wang. A new measure of software complexity. 2003.

[2] Y. Wang. A new measure of software complexity. 2006.

[3] P. A. McQuaid. The profile metric and software quality. 1997.

Conclusion/Possible Future Work

Additional control structures e.g. exception handling

Eye-tracking data may provide additional insight

Web app may be adapted for different purposes

  • Assess student proficiency in beginning programming classes
  • User-centric programming language design??? :/

Experiments with other programming paradigms e.g. functional and logic programming

An Experiment to Measure the Cognitive Weights of Code Control Structures

By David Adamo Jr.

An Experiment to Measure the Cognitive Weights of Code Control Structures

  • 460