arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2410.18989cs.CYcs.SE
收藏

学生条件语句中的反模式

Anti-patterns in Students' Conditional Statements

Etienne Naude, Paul Denny, Andrew Luxton-Reilly

AI总结:

该研究使用qChecker分析398名学生的41,032份Python提交,识别条件语句中的15种反模式,揭示其分布并提出计算教育改进建议。

摘要:

编写高质量代码至关重要,因为它能使代码库更易于维护,并降低与项目相关的成本和工作量。然而,学习编程的学生通常会收到简短的、自动评分的编程任务,他们未来不需要修改或维护这些任务。这可能导致低质量代码:尽管这些代码可能通过与问题相关的测试用例,却包含反模式——即常见出现但无效或适得其反的编程模式。本研究调查了Python入门课程学生提交的代码中与条件语句相关的反模式。我们的主要动机是了解新手代码中反模式的普遍程度和类型。我们分析了来自398名一年级学生的41,032份Python代码提交,使用开源“qChecker”工具识别15种与条件语句相关的特定反模式。研究结果显示,最常见的反模式是“if/else return bool”、“confusing else”和“nested if”,其中仅“if/else return bool”和“confusing else”就占观察到的反模式总数的近60%。这些反模式在各种实验练习中普遍存在,表明需要有针对性的教育干预。我们的主要贡献包括详细分析学生代码中的反模式,以及在计算教育环境中改进编码实践的建议。我们分析的提交也是在生成式AI工具出现之前收集的,提供了AI工具支持可用之前学生代码中存在问题的快照。

英文摘要:

Producing high-quality code is essential as it makes a codebase more maintainable, reducing the cost and effort associated with a project. However, students learning to program are often given short, automatically graded programming tasks that they do not need to alter or maintain in the future. This can lead to poor-quality code that, although it may pass the test cases associated with the problem, contains anti-patterns - commonly occurring but ineffective or counterproductive programming patterns. This study investigates anti-patterns relating to conditional statements in code submissions made by students in an introductory Python course. Our primary motivation is to understand the prevalence and types of anti-patterns that occur in novice code. We analyzed 41,032 Python code submissions from 398 first-year students, using the open-source "qChecker" tool to identify 15 specific anti-patterns related to conditional statements. Our findings reveal that the most common anti-patterns are "if/else return bool", "confusing else", and "nested if", with "if/else return bool" and "confusing else" alone constituting nearly 60% of the total anti-patterns observed. These anti-patterns were prevalent across various lab exercises, suggesting a need for targeted educational interventions. Our main contribution includes a detailed analysis of anti-patterns in student code, and recommendations for improving coding practices in computing education contexts. The submissions we analyse were also collected prior to the emergence of generative AI tools, providing a snapshot of the issues present in student code before the availability of AI tool support.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑