TY - GEN
T1 - Use of an Anti-Pattern in CS2
T2 - 54th ACM Technical Symposium on Computer Science Education, SIGCSE 2023
AU - Nurollahian, Sara
AU - Hooper, Matthew
AU - Salazar, Adriana
AU - Wiese, Eliane
N1 - Publisher Copyright:
© 2023 Owner/Author.
PY - 2023/3/2
Y1 - 2023/3/2
N2 - 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.
AB - 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.
KW - anti-patterns
KW - code readability
KW - code smell
KW - code structure
KW - conditional statements
KW - discourse rules
KW - exclusive ifs
KW - novice code
KW - programming patterns
KW - sequential if statements with exclusive conditions
KW - static code analyzer
UR - https://www.scopus.com/pages/publications/85149872980
U2 - 10.1145/3545945.3569744
DO - 10.1145/3545945.3569744
M3 - Conference contribution
AN - SCOPUS:85149872980
T3 - SIGCSE 2023 - Proceedings of the 54th ACM Technical Symposium on Computer Science Education
SP - 542
EP - 548
BT - SIGCSE 2023 - Proceedings of the 54th ACM Technical Symposium on Computer Science Education
PB - Association for Computing Machinery, Inc
Y2 - 15 March 2023 through 18 March 2023
ER -