Code Critique: Rich, Immediate Critiques of Coding Antipatterns
WebTA is a tool for automated code critique based on the dissertation "Critiquing Antipatterns In Novice Code" by Dr. Leo C. Ureel II (2020). It identifies common antipatterns in student code and generates pedagogically grounded feedback on five key aspects of programming: structure, behavior, style, design, and testing.
By identifying and critiquing antipatterns, WebTA supports novice programmers in developing better coding practices. The system integrates cognitive apprenticeship principles by providing timely, meaningful feedback that students can reflect upon while actively coding.
Structural critique identifies syntactic issues and code placement errors. For example, novice programmers often misplace executable code outside of method bodies, producing compilation errors that are opaque to beginners.
Example: Misplaced Code
public class Hello {
String s = "Hello World";
String result = "";
for (int i = 0; i < s.length(); i++) {
result = s.charAt(i) + result;
}
return result;
}
Critique: "This code appears to be executable statements placed outside of any method. Java only allows field and method declarations at the class level. Try moving this code inside a method such as public String reverse()
."
Behavioral critique focuses on runtime execution and functional correctness, often leveraging instructor-defined JUnit test cases. Antipatterns here include infinite loops, uncaught exceptions, and incorrect control flow.
Example: Array Index Out of Bounds
public int getElement(int[] arr, int index) {
return arr[index];
}
Critique: "Be sure to check whether index
is within the bounds of the array. An ArrayIndexOutOfBoundsException
can occur when accessing an array without validating the index."
Style critique uses static analysis to detect code that deviates from best practices or standard conventions. These issues don’t prevent execution but reduce readability and maintainability.
Example: Capitalized Variable
int Count = 5;
Critique: "Variable names should start with a lowercase letter to follow Java naming conventions. Consider renaming Count
to count
."
Design critique highlights issues related to architecture and code modularity. It involves deeper analysis using abstract syntax trees (ASTs) to identify novice antipatterns that are structurally sound but poorly designed.
Example: Interface Pseudo-Implementation
public class Reverse {
public String reverse(String s) {
return new StringBuilder(s).reverse().toString();
}
}
Critique: "It looks like you're implementing the ReverseInterface
, but forgot to declare implements ReverseInterface
. This means your class won’t satisfy type checks that rely on the interface."
- Static Analysis: Regular expression or AST-based pattern matching detects structural and style antipatterns.
Static analysis is employed to detect structural, syntactic, and stylistic antipatterns using pattern matching, regular expressions, and abstract syntax trees. This form of analysis operates without executing the code. Instead, it examines the source code to identify predefined markers of common mistakes. For example, rules may flag improper capitalization of variables, excessive method length, or misplaced code blocks. Through static analysis, WebTA provides instant feedback that guides students toward more idiomatic and maintainable coding styles.
- Dynamic Analysis: Unit testing frameworks (e.g., JUnit) identify behavioral faults through instructor-crafted test cases.
Dynamic analysis assesses the runtime behavior of programs by executing them against a set of predefined test cases, typically using a unit testing framework like JUnit. These tests evaluate functional correctness by checking whether the program outputs match expected results under various conditions. This allows WebTA to catch issues such as incorrect logic, failure to handle edge cases, or failure to throw required exceptions. Dynamic analysis bridges the gap between compilation success and actual correctness in execution.
- AST Traversal: Nodes are inspected for key indicators of design problems, such as the misuse of object-oriented constructs.
AST traversal involves parsing student code into a tree representation that mirrors its syntactic structure. Nodes in this tree represent constructs such as methods, loops, and conditionals. Traversal algorithms examine these nodes to detect misuses of language features or poor design patterns, such as methods without clear cohesion or objects that violate encapsulation. This deeper level of critique enables the system to comment not just on surface errors but on structural misalignments and flawed abstractions.
- Pseudocode Translation: Student code is translated to simplified pseudocode to normalize syntax and focus on structure.
To support meaningful critique even in the presence of syntax errors, WebTA employs a pseudocode translation technique that abstracts away language-specific quirks. This involves converting Java code into a simplified pseudocode representation to normalize variable names, method calls, and control structures. By doing so, it can analyze program logic even when the code does not compile. This is especially useful for critiquing novice code that may include valid logic embedded within malformed syntax.
This work was partly funded by the National Science Foundation awards #2142309 and #1504860.

