Use of an Anti-Pattern in CS2: Sequential if Statements with Exclusive Conditions

Use of an Anti-Pattern in CS2: Sequential if Statements with Exclusive Conditions
复制标题

CS2 中反模式的使用:具有独占条件的顺序 if 语句

DOI:
10.1145/3545945.3569744
复制
发表时间:
2023
期刊:
Proceedings of the 54th ACM Technical Symposium on Computer Science Education
影响因子:
--
通讯作者:
Wiese, Eliane
Wiese, Eliane
中科院分区:
--
文献类型:
--
作者:
Nurollahian, Sara;Hooper, Matthew;Salazar, Adriana;Wiese, Eliane

文献摘要

参考文献

被引文献

相似文献

我们如何教学生使用更具可读性的代码结构?学生选择可读性较差(但仍然实用)的替代方案有多常见?我们针对特定的反模式探索这些问题:当条件互斥时使用顺序 if 语句(而不是使用 else-if 或 else)。我们创建并验证了一个自动检测器来识别学生代码中的这种反模式。对 1,764 份作业提交(来自 CS2 数据结构和算法课程的 270 名学生)运行检测器表明,这种反模式很常见,并且因作业而异:在 12 份作业中,3% 到 50% 的作业对排他性案例使用了顺序 ifs。然而,使用这种反模式并不排除使用 else-if:在作业中,高达 34% 的提交内容同时使用了这两种形式。此外,学生以令人惊讶的方式使用顺序 if 语句,例如检查一个条件,然后否定该条件,这表明他们的理解水平比中级课程的预期水平要低。对检测器标记的案例进行手工检查表明,排他案例的顺序 if 可能是一种代码味道,可以表明逻辑和抽象方面存在更大的问题。
How can we teach students to use more readable code structures? How common is it for students to choose less readable (but still functional) alternatives? We explore these questions for a specific anti-pattern: using sequential if statements when conditions are exclusive (rather than using else-if or else). We created and validated an automated detector to identify this anti-pattern in student's code. Running the detector on 1,764 homework submissions (from 270 students in a CS2 class on data structures and algorithms) showed that this anti-pattern was common and varied by assignment: across 12 assignments, 3% to 50% of submissions used sequential ifs for exclusive cases. However, using this anti-pattern did not preclude using else-ifs: across assignments, up to 34% of the submissions used both forms. Further, students used sequential if statements in surprising ways, such as checking a condition and then the negation of that condition, indicating a more novice level of understanding than expected for an intermediate course. Hand-inspection of the detector-flagged cases suggests that sequential ifs for exclusive cases may be a code smell that can indicate larger problems with logic and abstraction.
DOI: --
发表时间: 2011
期刊: IFAC Symposium on Advances in Control Education
影响因子: --
作者:
Jacqueline L. Whalley;T. Clear;Phil Robbins;Errol Thompson
通讯作者: Errol Thompson
DOI: 10.1109/tse.1984.5010283
发表时间: 1984-09
影响因子: 7.4
作者:
E. Soloway;Kate Ehrlich
通讯作者: E. Soloway;Kate Ehrlich
Java 编程 24 小时培训师
DOI: --
发表时间: 2011
期刊:
影响因子: --
作者:
Yakov Fain
通讯作者: Yakov Fain
DOI: --
发表时间: 2019
期刊: Annual Conference on Innovation and Technology in Computer Science Education
影响因子: --
作者:
H. Keuning;B. Heeren;J. Jeuring
通讯作者: J. Jeuring
正在进行的工作:计算机本科生的代码质量问题
DOI: --
发表时间: 2022
期刊: IEEE Global Engineering Education Conference
影响因子: --
作者:
Oscar Karnalim;Simon;W. Chivers
通讯作者: W. Chivers