Back to Basics for APCS Success Stuart Reges, Principal Lecturer University of Washington Hélène Martin, CS teacher Garfield High School.

Slides:



Advertisements
Similar presentations
Topic 17 assertions and program logic
Advertisements

CSc 2310 Principles of Programming (Java)
COMS S1007 Object-Oriented Programming and Design in Java July 8, 2008.
Copyright 2006 by Pearson Education 1 Building Java Programs Chapter 5: Program Logic and Indefinite Loops.
Copyright 2006 by Pearson Education 1 Building Java Programs Chapter 8: Classes and Objects.
Class 1: What this course is about. Assignments Reading: Chapter 1, pp 1-33 Do in Class 1: –Exercises on pages 13, 14, 22, 28 To hand in in Class 2: –Exercises.
Copyright 2008 by Pearson Education 1 Midterm announcements Next week on Friday May 8 Must bring an ID Open book, open notes, closed electronics Must attend.
Back to Basics in CS1 and CS2 Stuart Reges University of Washington.
Copyright 2008 by Pearson Education Building Java Programs Chapter 7 Lecture 27: More on ArrayList, Reference Semantics Command Line Arguments reading:
Copyright 2008 by Pearson Education Building Java Programs Chapter 8 Lecture 8-1: Classes and Objects reading: self-checks: #1-9 exercises: #1-4.
Spring 2008 Mark Fontenot CSE 1341 Principles of Computer Science I Note Set 1 1.
Spring 2008 Mark Fontenot CSE Honors Principles of Computer Science I Note Set 1 1.
Welcome to IIT and cs115!.
Python at Cypress Woods. About Cy-Woods Northwest of Houston Roughly 3,500 students Part of Cy-Fair ISD with 100,000+ students Cypress Woods High School.
Copyright 2008 by Pearson Education Building Java Programs Chapter 8 Lecture 8-2: Constructors and Encapsulation reading: self-checks: #10-17.
CSCE 1040 Computer Science 2 First Day. Course Dr. Ryan Garlick Office: Research Park F201 B –Inside the Computer Science department.
CSCI 51 Introduction to Computer Science Dr. Joshua Stough January 20, 2009.
1 Logical Assertions. 2 Logical assertions assertion: A statement that is either true or false. Examples: –Java was created in –The sky is purple.
Copyright 2008 by Pearson Education Building Java Programs Chapter 8 Lecture 8-3: Encapsulation, this reading: self-checks: #13-17 exercises:
Topic 27 classes and objects, state and behavior Copyright Pearson Education, 2010 Based on slides bu Marty Stepp and Stuart Reges from
1 Building Java Programs Chapter 5 Lecture 5-2: Random Numbers reading: 5.1, 5.6.
An Update on UW Intro Classes Stuart Reges Principal Lecturer University of Washington.
1 CSE 142 Midterm Review Problems These lecture notes are copyright (C) Marty Stepp and Stuart Reges, They may not be rehosted, sold, or modified.
Object Oriented Programming. OOP  The fundamental idea behind object-oriented programming is:  The real world consists of objects. Computer programs.
Welcome to the Computer Science classes Mrs. Whitlock AP night Chattahoochee High School.
Copyright 2009 by Pearson Education Building Java Programs Chapter 5 Lecture 5-3: Boolean Logic reading: 5.2 self-check: # exercises: #12 videos:
Copyright 2009 by Pearson Education Building Java Programs Chapter 8: Classes Lecture 8-3: More Critters, static.
Topic 27 classes and objects, state and behavior Copyright Pearson Education, 2010 Based on slides bu Marty Stepp and Stuart Reges from
September 5, 2006Introduction 1 of 6 WELCOME TO CS15!
Spring 2008 Mark Fontenot CSE 1341 – Honors Principles of Computer Science I Note Set 1 1.
Copyright 2010 by Pearson Education Building Java Programs Chapter 8 Lecture 8-3: Constructors; Encapsulation reading: self-checks: #13-18,
Building Java Programs
Adapted from slides by Marty Stepp and Stuart Reges
Analysis and Comparison is ICS4U
Loops CS140: Introduction to Computing 1 Savitch Chapter 4 Flow of Control: Loops 9/18/13 9/23/13.
Adapted from slides by Marty Stepp and Stuart Reges
Building Java Programs
Building Java Programs
Building Java Programs
Welcome to the Computer Science classes
Adapted from slides by Marty Stepp and Stuart Reges
Object initialization: constructors
Topic 28 classes and objects, part 2
Building Java Programs
Building Java Programs
Logical assertions assertion: A statement that is either true or false. Examples: Java was created in The sky is purple. 23 is a prime number. 10.
Topic 29 classes and objects, part 3
Topic 17 assertions and program logic
Topic 27 classes and objects, state and behavior
Adapted from slides by Marty Stepp and Stuart Reges
Building Java Programs
Lecture 12: 2D Arrays AP Computer Science Principles
References and objects
Building Java Programs
Building Java Programs
Building Java Programs
Using Objects (continued)
Building Java Programs
Building Java Programs
A programming problem Given a file of cities' (x, y) coordinates, which begins with the number of cities: Write.
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Topic 29 classes and objects, part 3
Building Java Programs
Building Java Programs
Topic 29 classes and objects, part 3
Presentation transcript:

Back to Basics for APCS Success Stuart Reges, Principal Lecturer University of Washington Hélène Martin, CS teacher Garfield High School

Selective Timeline 1984: AP/CS first offered in Pascal : AP/CS switches to C : Dot com crash, CS enrollments plummet 2002: OOPSLA “Resolved: Objects have Failed” : AP/CS switches to Java 2005: SIGCSE “Resolved: Objects Early has Failed” 2011: CMU and Berkeley switch CS1 to Python 2011: Stuart Reges assures nervous teachers that AP/CS in Java is a fantastic course

More personal timeline 2000: “Conservatively Radical Java in CS1”: objects early through scaffolding 2004: Stuart hired by UW to fix intro with a plan to teach procedural Java 2005: Resolved: Objects Early has Failed 2006: first edition of Building Java Programs 2011: 4 textbooks with “objects late” in title, 3rd edition of Building Java Programs

UW Results

Course Principles Traditional procedural approach (back to basics): drawing on past wisdom Updated to use features of Java: using objects early, graphics (DrawingPanel) Core of the course: challenging assignments many of which are nifty or practical Concrete practice problems to build programming skills: section problems, labs, exams, PracticeIt Lots of support: army of undergraduate TAs, programming lab support

Why I’m sold “I've never come across a textbook that layers ideas so strategically and ingeniously well. The ideas are presented in an order and in a manner that made it impossible for me to get lost or bored. [...] It taught so well, I couldn't wait to get my hands on problem after problem. This book made me crave problem solving and writing clean, inventive, non-redundant, well-commented code.” - Amazon reviewAmazon review Applies to methodology; book is a nice-to-have! 6

First offering of APCS in the district 26 students enrolled, 17 took AP test

Advanced section for 25 students 2 sections for students new to programming 32% women overall (37% in new sections)

Garfield course structure 1/4 lecture, group work without computers In-class time for experimenting Programming projects written from scratch Little to no homework Bi-weekly paper and pencil quizzes No real mention of AP test until February

Students know OOP January: writing classes as object blueprints Sophisticated Gridworld projects 15-puzzle snake game ant farm Heavily OO final projects AP report mean for OO multiple choice: 6.4, 4.9 nationally; group mean close to 7 on FRQ

Assertions: verifying mental models public static void mystery(int x, int y) { int z = 0; // Point A while (x >= y) { // Point B x = x - y; z++; if (x != y) { // Point C z = z * 2; } // Point D } // Point E System.out.println(z); } x < yx == yz == 0 Point A Point B Point C Point D Point E Which of the following assertions are true at which point(s) in the code? Choose ALWAYS, NEVER, or SOMETIMES.

Assertions: verifying mental models public static void mystery(int x, int y) { int z = 0; // Point A while (x >= y) { // Point B x = x - y; z++; if (x != y) { // Point C z = z * 2; } // Point D } // Point E System.out.println(z); } x < yx == yz == 0 Point A SOMETIMES ALWAYS Point B NEVERSOMETIMES Point C SOMETIMESNEVER Point D SOMETIMES NEVER Point E ALWAYSNEVERSOMETIMES Which of the following assertions are true at which point(s) in the code? Choose ALWAYS, NEVER, or SOMETIMES.

Reasoning about assertions Right after a variable is initialized, its value is known: int x = 3; // is x > 0? ALWAYS In general you know nothing about parameters' values: public static void mystery(int a, int b) { // is a == 10? SOMETIMES But inside an if, while, etc., you may know something: public static void mystery(int a, int b) { if (a < 0) { // is a == 10? NEVER... } 13

Assertions and loops At the start of a loop's body, the loop's test must be true : while (y < 10) { // is y < 10? ALWAYS... } After a loop, the loop's test must be false : while (y < 10) {... } // is y < 10? NEVER Inside a loop's body, the loop's test may become false : while (y < 10) { y++; // is y < 10? SOMETIMES } 14

“Sometimes” Things that cause a variable's value to be unknown: reading from a Scanner choosing a random value a parameter's initial value to a method 15

Transition to OOP 16

Modeling earthquakes Given a file of cities' (x, y) coordinates, which begins with the number of cities: Write a program to draw the cities on a DrawingPanel, then model an earthquake by turning affected cities red: Epicenter x? 100 Epicenter y? 100 Affected radius? 75

public void print() { // this code can see p2's x and y } Point objects w/ method Each Point object has its own copy of the print method, which operates on that object's state: Point p1 = new Point(); p1.x = 7; p1.y = 2; Point p2 = new Point(); p2.x = 4; p2.y = 3; p1.print(); p2.print(); public void print() { // this code can see p1's x and y } x 7 y 2 p2 p1 x 4 y 3

Why encapsulation? Ab straction between object and clients Protects object from unwanted access Example: Can't fraudulently increase an Account 's balance. Can change the class implementation later Example: Point could be rewritten in polar coordinates ( r, θ ) with the same methods. Can constrain objects' state (invariants) Example: Only allow Account s with non-negative balance. Example: Only allow Date s with a month from