早期职业开发者对代码可理解性的认知:一项关于复杂度度量的研究
Early Career Developers' Perceptions of Code Understandability. A Study of Complexity Metrics
AI总结:
该研究针对216名1-4年经验的早期职业开发者开展实证研究,探究McCabe圈复杂度与认知复杂度对代码可理解性的预测效果,发现二者预测能力一般且无法预测问题严重度,建议不让早期开发者独立做代码评审。
摘要:
研究背景:代码可理解性是基础性的。开发者需要清晰理解他们正在修改的代码。可理解性低会增加编码工作量,而对代码的误解会影响整个开发流程。理想情况下,开发者应以最少的精力写出清晰易懂的代码。研究目的:本工作探究McCabe圈复杂度(McCabe Cyclomatic Complexity)与认知复杂度(Cognitive Complexity)能否作为开发者感知的代码可理解性的良好预测指标,以明确两种复杂度中哪一种可作为评估代码是否易懂的标准。研究方法:我们设计并开展了一项实证研究,研究对象为216名职业经验在1到4年的早期职业开发者。我们要求他们手动检查并评估12个Java类的可理解性,这些类呈现出不同水平的圈复杂度与认知复杂度。研究结果:我们的发现表明,对于早期职业开发者感知的复杂度而言,传统的McCabe圈复杂度与近年提出的认知复杂度对代码可理解性的预测能力一般,但二者无法预测问题严重程度。研究结论:基于研究结果,由于早期职业开发者经验不足,不应让他们独立执行代码评审任务。此外,低复杂度度量值意味着良好的可理解性,但只要认知复杂度(CoC)或圈复杂度(CyC)其中一项偏高,可理解性就会变得不可预测。不过,目前没有证据表明圈复杂度或认知复杂度是早期职业开发者感知的问题严重程度的指标。未来的研究将致力于把研究群体扩展到经验丰富的开发者,以验证从业年限是否会影响所选度量指标的预测能力。
英文摘要:
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.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。