An Empirical Study of Code Pattern Reuse and Pattern Preference Consistency in Novice Programmers
摘要
After learning the basic features of a programming language, such as expressions and control statements, novice programmers need to combine these features to solve programming questions. Some of these combined code snippets are reusable constructs useful to solve future questions. They are referred to as plans, schemas, or patterns in the literature. An example of such a pattern is determining the equality of three values using the ‘equal and logical and operators. Previous research has investigated the acquisition of these patterns by observing and interviewing novice programmers as they solve programming problems. In this paper, we test the hypothesis that students tend to reuse acquired patterns to solve subsequent problems by analyzing a computer science education dataset called CodeWorkout, which contains students’ code submissions for introductory-level programming questions. We employed directed labeled tree to represent the Abstract Syntax Tree (AST) of the submitted code and the patterns. To search for a pattern, we first applied the subgraph isomorphism algorithm VF2 with wildcard node labels to identify candidate matches, followed by enforcing the proper ordering of descendant nodes between the pattern and the candidate matches. Experimental results demonstrate that our approach effectively identifies common usage of patterns. Moreover, the findings indicate that if a student employs a pattern in one question, they are likely to reuse the same pattern in a subsequent question. This paper also reveals that when multiple alternative patterns exist for the same function, students tend to maintain their preference for a particular alternative while solving different questions. These insights can inform future curriculum design and instructional strategies in programming education.