Abstract
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 | English |
---|---|
Title of host publication | 22nd International Conference on Program Comprehension, ICPC 2014 - Proceedings |
Publisher | Association for Computing Machinery |
Pages | 189-200 |
Number of pages | 12 |
ISBN (Electronic) | 9781450328791 |
DOIs | |
State | Published - 2 Jun 2014 |
Event | 22nd International Conference on Program Comprehension, ICPC 2014 - Hyderabad, India Duration: 2 Jun 2014 → 3 Jun 2014 |
Publication series
Name | 22nd International Conference on Program Comprehension, ICPC 2014 - Proceedings |
---|
Conference
Conference | 22nd International Conference on Program Comprehension, ICPC 2014 |
---|---|
Country/Territory | India |
City | Hyderabad |
Period | 2/06/14 → 3/06/14 |
Bibliographical note
Publisher Copyright:Copyright © 2014 ACM.
Keywords
- Code complexity
- Code regularity
- LOC
- MCC