On the effect of code regularity on comprehension

Ahmad Jbara, Dror G. Feitelson

Research output: Chapter in Book/Report/Conference proceedingConference contributionpeer-review

26 Scopus citations

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 languageEnglish
Title of host publication22nd International Conference on Program Comprehension, ICPC 2014 - Proceedings
PublisherAssociation for Computing Machinery
Pages189-200
Number of pages12
ISBN (Electronic)9781450328791
DOIs
StatePublished - 2 Jun 2014
Event22nd International Conference on Program Comprehension, ICPC 2014 - Hyderabad, India
Duration: 2 Jun 20143 Jun 2014

Publication series

Name22nd International Conference on Program Comprehension, ICPC 2014 - Proceedings

Conference

Conference22nd International Conference on Program Comprehension, ICPC 2014
Country/TerritoryIndia
CityHyderabad
Period2/06/143/06/14

Bibliographical note

Publisher Copyright:
Copyright © 2014 ACM.

Keywords

  • Code complexity
  • Code regularity
  • LOC
  • MCC

Fingerprint

Dive into the research topics of 'On the effect of code regularity on comprehension'. Together they form a unique fingerprint.

Cite this