Skip to main content
QUICK REVIEW

[Paper Review] Early Career Developers' Perceptions of Code Understandability. A Study of Complexity Metrics

Esposito, Matteo, Andrea Janes|arXiv (Cornell University)|Mar 14, 2023
Software Engineering ResearchComputer Science3 citations
TL;DR

This empirical study evaluates whether Cyclomatic Complexity or Cognitive Complexity better predicts developers' perceived code understandability. Among 216 junior developers, Cognitive Complexity showed a slightly stronger correlation with perceived understandability than Cyclomatic Complexity, though neither metric was a strong predictor overall.

ABSTRACT

Context. Code understandability is fundamental. Developers need to understand the code they are modifying clearly. A low understandability can increase the amount of coding effort, and misinterpreting code impacts the entire development process. Ideally, developers should write clear and understandable code with the least effort. Aim. Our work investigates whether the McCabe Cyclomatic Complexity or the Cognitive Complexity can be a good predictor for the developers' perceived code understandability to understand which of the two complexities can be used as criteria to evaluate if a piece of code is understandable. Method. We designed and conducted an empirical study among 216 early career developers with professional experience ranging from one to four years. We asked them to manually inspect and rate the understandability of 12 Java classes that exhibit different levels of Cyclomatic and Cognitive Complexity. Results. Our findings showed that while the old-fashioned McCabe Cyclomatic Complexity and the most recent Cognitive Complexity are modest predictors for code understandability when considering the complexity perceived by early-career developers, they are not for problem severity. Conclusions. Based on our results, early-career developers should not be left alone when performing code-reviewing tasks due to their scarce experience. Moreover, low complexity measures indicate good understandability, but having either CoC or CyC high makes understandability unpredictable. Nevertheless, there is no evidence that CyC or CoC are indicators of early-career perceived severity.Future research efforts will focus on expanding the population to experienced developers to confront whether seniority influences the predictive power of the chosen metrics.

Motivation & Objective

  • To investigate which of two code complexity metrics—Cyclomatic or Cognitive Complexity—better predicts developers' perception of code understandability.
  • To assess whether higher complexity levels correlate with perceived severity of code problems in software classes.
  • To validate the effectiveness of Cognitive Complexity as a metric for code understandability, given its recent introduction and limited empirical support.
  • To provide evidence-based insights for static analysis tools and software development practices on complexity metrics.
  • To explore the gap between theoretical complexity metrics and real-world developer perception in early-career software developers.

Proposed method

  • Recruited 216 junior developers (bachelor and master level students) with 1–4 years of professional experience.
  • Selected 12 Java classes with varying levels of Cyclomatic and Cognitive Complexity as measured by SonarQube.
  • Conducted a manual inspection task where developers rated the understandability of each class on a standardized scale.
  • Collected additional ratings on perceived severity of code problems in each class to assess correlation with complexity metrics.
  • Used statistical analysis to compare the predictive power of Cyclomatic Complexity and Cognitive Complexity on perceived understandability.
  • Employed a controlled, within-subjects design to ensure consistent evaluation conditions across all participants and code samples.
Figure 1 : Empirical study design process
Figure 1 : Empirical study design process

Experimental results

Research questions

  • RQ1Does Cognitive Complexity correlate more strongly with developers' perceived code understandability than Cyclomatic Complexity?
  • RQ2Are classes with higher Cyclomatic or Cognitive Complexity perceived as having more severe code problems?
  • RQ3Is there a significant difference in perceived understandability between classes with varying levels of complexity metrics?
  • RQ4Do junior developers consistently rate code understandability based on complexity metrics, or are other factors more influential?
  • RQ5Can Cognitive Complexity serve as a reliable proxy for code understandability in practice, given its recent introduction?

Key findings

  • Cognitive Complexity demonstrated a slightly better correlation with developers' perceived code understandability than Cyclomatic Complexity.
  • The overall correlation between either complexity metric and perceived understandability was weak, indicating limited predictive power.
  • No significant correlation was found between complexity levels (Cyclomatic or Cognitive) and the perceived severity of code problems.
  • Classes with higher complexity were not consistently rated as having more severe issues, challenging assumptions about complexity and maintainability.
  • The results suggest that neither Cyclomatic nor Cognitive Complexity alone is a strong predictor of perceived code understandability among junior developers.
  • The study highlights the need for further research into alternative or complementary metrics for assessing code understandability.
Figure 2 : Perceived Code Understandability distribution (RQ 1 )
Figure 2 : Perceived Code Understandability distribution (RQ 1 )

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.