Academic Bug Patterns Stuart Hansen University of Wisconsin - Parkside
Bug Patterns Recurring software defects Term coined by Eric Allen Bug Patterns in Java, APress, 2002 Academic Bug Patterns –Occur in student code –Not only “gotchas”
Motivation Understanding our students’ bugs helps us teach them to –Find and remove them –Avoid them Places empirical data behind our expertise –May give added insights
Object-Oriented Programming New Programming Paradigm → New bug Patterns Does OOP Really Match the Way we Think?, Les Hatton, IEEE Software 1998 –OOP programs are buggier and take longer to debug than procedural programs.
We are Experts Already To a large extent we are already experts in academic bug patterns –CS1 and CS2 “gotchas” –Using symbolic constants –Problem decomposition Textbooks include headings like –Common Programming Errors –Helpful Reminders
Survey Two Classes –Data Structures and Algoritms –Event Driven Programming Two Questions: –What was the most difficult bug/problem you encountered doing the assignment? –What did you do to resolve it?
Survey - continued Intentionally wide open Didn’t want to impose a taxonomy Total of 56 surveys collected on 6 different assignments
Results 19 Language and Tools Bugs 13 Strong Coupling Bugs 11 Local/Instance Bugs 6 Blame the Instructor Bugs
Languages and Tools Pattern 19/56 = 34% of all bugs reported Lots of new stuff still being introduced –Swing –Microsoft.Net Programming –CORBA/RMI Biggest student desire seems to be for brief cogent examples
Languages and Tools Sol’ns Search the Internet Ask someone in class Only 1 student reported reading the text to find the solution!
Strong Coupling Bugs 13/56 = 23% of all bugs reported Event Driven Programming starts with lots of GUI material. –Model-View-Controller –Multi-threading “When I came up one solution to a problem, it often caused new problems in other areas.”
Strong Coupling - Continued Students wrote long paragraphs describing how they solved their problems. No discernable patterns to their approaches. We probably don’t teach enough design patterns early in our curriculum.
Local State/Object State Bug 11/56 = 20% of all bugs reported Students didn’t see whether data should be local, instance or belong to some sort of global data store. Particularly true in game programming –Boggle and Connect 4 –Students have been introduced to recursion, but haven’t applied it much on their own.
Local/Object – Continued Basic truth not in texts is that M-V-C requires redundant state! “When I clicked the Undo button, the screen would clear the last move, but inside the memory the program did not actually clear the data.”
Brief Aside: O-OP is gradually making its way into D.S. and Alg. courses. Many texts still have Pascal look and feel. Tension between O-OP and D.S. and Alg. –RedBlack trees require non-global, but more than local knowledge. –Null design pattern works, but an “if” may be clearer
Polymorphism Bugs 8/56 = 14% of all bugs reported Java GUIs are fundamentally polymorphic –Use inheritance to build interfaces –Register handlers Also in D.S. and Algs. –2D Trees, e.g. BSTs based on (X,Y) points. Registration is easier polymorphism related pattern than others
Blame the Instructor - Bugs 6/56 = 11% of all bugs reported Anonymous survey is good opportunity to let loose on instructor Two main complaints –Instructor code sometimes buggy –Program specs sometimes not clear enough
Summary 1.“See one, do one” is dominant learning model for our students. 2.Languages, tools and libraries are growing more and more complex. 3.Object-oriented design still poses major challenges.
Questions?