Although writing code seems trivial at times, problems arise when humans misinterpret what the code actually does. One of the potential causes are "atoms of confusion", the smallest possible patterns of misinterpretable source code. Previous research has investigated the impact of atoms of confusion in C code. Results show that developers make significantly more mistakes in code where atoms are present. In this paper, we replicate the work of Gopstein et al. to the Java language. After deriving a set of atoms of confusion for Java, we perform a two-phase experiment with 132 computer science students (i.e., novice developers). Our results show that participants are 2.7 up to 56 times more likely to make mistakes in code snippets affected by 7 out of the 14 studied atoms of confusion, and when faced with both versions of the code snippets, participants perceived the version affected by the atom of confusion to be more confusing and/or less readable in 10 out of the 14 studied atoms of confusion.
翻译:虽然书写代码有时显得微不足道,但当人们曲解代码的实际作用时,就会出现问题。 潜在原因之一是“ 混乱的原子 ”, 可能最小的错误源代码模式。 先前的研究已经调查了C代码中混乱原子的影响。 结果显示,开发商在原子存在的代码中犯的错误要多得多。 在本文中,我们把Gopstein et al. 的作品复制到爪哇语中。 在为爪哇产生一系列混乱的原子之后,我们与132名计算机科学学生(即新开发商)进行了两阶段实验。 我们的结果表明,参与者在受14个被研究的混乱原子中7个影响的代码片中犯错误的可能性高达2.7至56倍。 当面对两个版本的代码片断时, 参与者认为, 被混乱的原子影响到的版本在14个被研究的混乱原子中的10个中更加混乱和(或)不易读。