It is naturally easier to comprehend simple code relative to complicated code. Regrettably, there is little agreement on how to effectively measure code complexity. As a result simple generalpurpose metrics are often used, such as lines of code (LOC), Mc- Cabe's cyclomatic complexity (MCC), and Halstead's metrics. But such metrics just count syntactic features, and ignore details of the code's global structure, which may also have an effect on understandability. In particular, we suggest that code regularity-where the same structures are repeated time after time-may significantly reduce complexity, because once one figures out the basic repeated element it is easier to understand additional instances. We demonstrate this by controlled experiments where subjects perform cognitive tasks on different versions of the same basic function. The results indicate that versions with significant regularity lead to better comprehension, while taking similar time, despite being longer and having higherMCC. These results indicate that regularity is another attribute of code that should be taken into account in the context of studying the code's complexity and comprehension. Moreover, the fact that regularity may compensate for LOC and MCC demonstrates that complexity cannot be decomposed into independently addable contributions by individual attributes.
|Original language||American English|
|Title of host publication||22nd International Conference on Program Comprehension, ICPC 2014 - Proceedings|
|Publisher||Association for Computing Machinery|
|Number of pages||12|
|State||Published - 2 Jun 2014|
|Event||22nd International Conference on Program Comprehension, ICPC 2014 - Hyderabad, India|
Duration: 2 Jun 2014 → 3 Jun 2014
|Name||22nd International Conference on Program Comprehension, ICPC 2014 - Proceedings|
|Conference||22nd International Conference on Program Comprehension, ICPC 2014|
|Period||2/06/14 → 3/06/14|
Bibliographical notePublisher Copyright:
Copyright © 2014 ACM.
- Code complexity
- Code regularity