Skip to main content
QUICK 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 Science被引用 3
一句话总结

本实证研究评估了环路复杂度与认知复杂度中哪一个更能预测开发者对代码可理解性的主观感受。在216名初级开发者中,认知复杂度与感知可理解性之间的相关性略强于环路复杂度,但两者整体预测能力均较弱。

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.

研究动机与目标

  • 调查两种代码复杂度度量标准——环路复杂度与认知复杂度——中,哪一种更能预测开发者对代码可理解性的主观感受。
  • 评估更高的复杂度水平是否与软件类中感知到的代码问题严重性相关。
  • 在认知复杂度近期提出且实证支持有限的背景下,验证其作为代码可理解度度量标准的有效性。
  • 为静态分析工具和软件开发实践提供基于证据的见解,以指导复杂度度量标准的选择。
  • 探讨理论复杂度度量标准与早期职业软件开发者实际感知之间的差距。

提出的方法

  • 招募了216名初级开发者(本科及硕士水平学生),其专业经验为1至4年。
  • 选取了12个Java类,其环路复杂度与认知复杂度由SonarQube测量,复杂度水平各不相同。
  • 开展人工检查任务,要求开发者在标准化量表上对每个类的可理解性进行评分。
  • 收集了关于每个类中感知到的代码问题严重性的额外评分,以评估其与复杂度度量标准的相关性。
  • 使用统计分析方法比较环路复杂度与认知复杂度在预测感知可理解性方面的表现。
  • 采用受控的、被试内设计,以确保所有参与者和代码样本的评估条件一致。
Figure 1 : Empirical study design process
Figure 1 : Empirical study design process

实验结果

研究问题

  • RQ1认知复杂度是否与开发者对代码可理解性的主观感受具有比环路复杂度更强的相关性?
  • RQ2复杂度水平更高的类是否被认为具有更严重的问题?
  • RQ3在不同复杂度水平的类之间,感知可理解性是否存在显著差异?
  • RQ4初级开发者是否一致地根据复杂度度量标准来评估代码可理解性,还是其他因素更具影响力?
  • RQ5鉴于认知复杂度是近期提出的,它能否在实践中作为代码可理解性的可靠代理?

主要发现

  • 认知复杂度与开发者对代码可理解性的主观感受之间的相关性略优于环路复杂度。
  • 两种复杂度度量标准与感知可理解性之间的总体相关性较弱,表明其预测能力有限。
  • 未发现复杂度水平(环路复杂度或认知复杂度)与感知到的代码问题严重性之间存在显著相关性。
  • 复杂度较高的类并未被一致认为问题更严重,这挑战了复杂度与可维护性之间关系的既有假设。
  • 结果表明,环路复杂度与认知复杂度均无法单独作为初级开发者对代码可理解性感知的强预测指标。
  • 本研究强调了未来需要探索替代或互补的度量标准,以更有效地评估代码可理解性。
Figure 2 : Perceived Code Understandability distribution (RQ 1 )
Figure 2 : Perceived Code Understandability distribution (RQ 1 )

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。