What Does Control Flow Really Look Like? Eyeballing the Cyclomatic Complexity Metric

What Does Control Flow Really Look Like? Eyeballing the Cyclomatic Complexity Metric
复制标题

DOI:
10.1109/scam.2012.17
复制
发表时间:
2012-09
期刊:
2012 IEEE 12th International Working Conference on Source Code Analysis and Manipulation
影响因子:
--
通讯作者:
J. Vinju;Michael W. Godfrey
J. Vinju;Michael W. Godfrey
中科院分区:
其他
文献类型:
--
作者:
J. Vinju;Michael W. Godfrey

文献摘要

被引文献

相似文献

评估源代码的可理解性仍然是软件开发人员及其管理人员的一个难以捉摸但非常理想的目标。虽然许多指标已经提出并进行了实证研究,麦凯布圈复杂性指标(CC)-这是基于控制流的复杂性-似乎持有持久的魅力,在工业界和研究界,尽管其已知的局限性。在这项工作中,我们介绍了控制流模式(CFPs)和压缩控制流模式(CCFPs)的想法,它消除了一些重复的结构,从控制流图,以强调高熵图。我们研究了八个著名的开源Java系统分组的CFPs的方法成等价类,并探索结果。我们观察到几个令人惊讶的结果:第一,独特的CFPs的数量相对较低,第二,CC通常不能准确反映Java控制流的复杂性,第三,具有高CC的方法通常具有非常低的熵,这表明它们可能相对容易理解。这些发现挑战了广泛持有的信念,CC和可理解性之间存在明确的因果关系,并建议CC和类似的措施需要重新考虑作为代码可理解性的指标。
Assessing the understandability of source code remains an elusive yet highly desirable goal for software developers and their managers. While many metrics have been suggested and investigated empirically, the McCabe cyclomatic complexity metric (CC) - which is based on control flow complexity - seems to hold enduring fascination within both industry and the research community despite its known limitations. In this work, we introduce the ideas of Control Flow Patterns (CFPs) and Compressed Control Flow Patterns (CCFPs), which eliminate some repetitive structure from control flow graphs in order to emphasize high-entropy graphs. We examine eight well-known open source Java systems by grouping the CFPs of the methods into equivalence classes, and exploring the results. We observed several surprising outcomes: first, the number of unique CFPs is relatively low, second, CC often does not accurately reflect the intricacies of Java control flow, and third, methods with high CC often have very low entropy, suggesting that they may be relatively easy to understand. These findings challenge the widely-held belief that there is a clear-cut causal relationship between CC and understandability, and suggest that CC and similar measures need to be reconsidered as metrics for code understandability.