Well structured and readable source code is a pre-requisite for maintainable software and successful collaboration among developers. Static analysis enables the automated extraction of code complexity and readability metrics which can be leveraged to highlight potential improvements in code to both attain software of high quality and reinforce good practices for developers as an educational tool. This assumes reliable readability metrics which are not trivial to obtain since code readability is somewhat subjective. Recent research has resulted in increasingly sophisticated models for predicting readability as perceived by humans primarily with a procedural and object oriented focus, while functional and declarative languages and language extensions advance as they often are said to lead to more concise and readable code. In this paper, we investigate whether the existing complexity and readability metrics reflect that wisdom or whether the notion of readability and its constituents requires overhaul in the light of programming language changes. We therefore compare traditional object oriented and reactive programming in terms of code complexity and readability in a case study. Reactive programming is claimed to increase code quality but few studies have substantiated these claims empirically. We refactored an object oriented open source project into a reactive candidate and compare readability with the original using cyclomatic complexity and two state-of-the-art readability metrics. More elaborate investigations are required, but our findings suggest that both cyclomatic complexity and readability decrease significantly at the same time in the reactive candidate, which seems counter-intuitive. We exemplify and substantiate why readability metrics may require adjustment to better suit popular programming styles other than imperative and object-oriented to better match human expectations.
翻译:良好的结构化和可读源码是开发者之间可维护的软件和成功合作的先决条件。 静态分析能够自动提取代码复杂度和可读度衡量标准,可以用来突出代码方面的潜在改进,既能达到高质量软件,又能加强开发者作为教育工具的良好做法。这假定可靠的可读性衡量标准,这些衡量标准并非微不足道,因为代码可读性是比较主观的。最近的研究产生了预测可读性越来越复杂的模型,主要以程序和目标为重点,而功能性和宣示性语言和语言扩展推进,因为人们常说它们会导致更简洁和可读性代码。在本文件中,我们调查现有的复杂度和可读性衡量度衡量标准是否反映了这种智慧,或读性概念及其组成部分是否需要根据方案语言的变化加以修改。因此,我们在案例研究中将传统的面向对象和反应性方案编制方法在代码复杂性和可读性方面进行了比较。 重新编程要求提高代码质量,但从经验上证实这些说法的研究很少。我们将目标导向的开放源项目重新定位为可反应的可读性候选人,并且将原始的易读性比原始的易读性更难理解性指标性更难理解性调查。我们看来要求的复杂性和更难理解性更难于预测性。