140 likes | 326 Views
Back to Basics in CS1 and CS2. Stuart Reges University of Washington. In a Nutshell…. Major redesign of the CS1/CS2 courses at the University of Washington New CS1 emphasizes procedural programming, objects later
E N D
Back to Basicsin CS1 and CS2 Stuart Reges University of Washington
In a Nutshell… • Major redesign of the CS1/CS2 courses at the University of Washington • New CS1 emphasizes procedural programming, objects later • New CS2 includes OOP concepts and traditional concepts (recursion, linked lists, binary trees) with a “collections” theme • Student satisfaction up; enrollment up; female admissions up
I used to believe Programs with sophisticated graphics and GUIs would be more fun for CS1 students than console and file based programs I found: They were often less fun I now believe: Students enjoy writing complete programs Students prefer standard Java Graphics gets old fast Our “sophisticated” programs are fairly crude The problem solving challenge is more important than surface appearance
Confession: I have them write a program that produces this (console output, ascii art): /**\ //**\\ ///**\\\ ////**\\\\ /////**\\\\\ +=*=*=*=*=*=*+ |../\..../\..| |./\/\../\/\.| |/\/\/\/\/\/\| |\/\/\/\/\/\/| |.\/\/..\/\/.| |..\/....\/..| +=*=*=*=*=*=*+ |\/\/\/\/\/\/| |.\/\/..\/\/.| |..\/....\/..| |../\..../\..| |./\/\../\/\.| |/\/\/\/\/\/\| +=*=*=*=*=*=*+ /**\ //**\\ ///**\\\ ////**\\\\ /////**\\\\\
I used to believe • I could teach object oriented design in CS1 instead of procedural design • I found: • Java objects involve a lot of syntactic detail • There are no 50-100 line programs where OOD helps • Many object based assignments end up being “paint by numbers” rather than problem solving • Many students don’t get the object concept • I now believe: • A large number of mid-level students who can master procedural concepts (loops, conditionals, methods, parameters, arrays) struggle with the object concept • Therefore, it is better to start with procedural programming if you have a broad audience
Confession: I have my students write code like this (with static methods): • public class DrawFigure { • public static final int SUB_HEIGHT = 3; • public static void main(String[] args) { • drawLine(); • drawTop(); • drawBottom(); • drawLine(); • } • // Produces a solid line • public static void drawLine() { • System.out.print("+"); • for (int column = 1; column <= (2 * SUB_HEIGHT); column++) { • System.out.print("-"); • } • System.out.println("+"); • } • ... • }
A few more CS1 details • Students use objects early, define them later • We use a custom DrawingPanel to explore objects (Graphics, Color, …) • Scanner is helpful for console and file input: while (input.hasNextLine()) { String text = input.nextLine(); Scanner data = new Scanner(text); <process data> } • Input files make programs interesting
Some objections • Stuart is guilty of crimes against Java • I’ve been in trouble before • Why not a procedural language like Python for CS1? • We’re using Java in CS2 and switching languages is tough for mid-level students • Why do you have to use the s-word so much? • Procedural Object Oriented Programming is a slippery slope (look what it spells)
A few words about CS2 • Eliminated some useful but less fundamental topics (GUIs, junit testing, javadoc, streams) • Brought back emphasis on fundamentals (recursion, linked lists, binary trees) including recursive backtracking • Less emphasis on OO design, but basic OO concepts included (encapsulation, inheritance, interfaces) including a client view of data structures • Collections framework as a “case study”
Conclusions • New courses are working for us • Impossible to tell which changes have helped the most • Too early to infer long-term trend (particularly with female admission) • We serve as an “existence proof” that back to basics can work
For more information • http://www.cs.washington.edu/homes/reges • Building Java Programs by Stuart Reges and Marty Stepp, Addison Wesley, expected early 2007