1 Scratching the Itch Jeff Parker, Merrimack College Scratch@MIT The primary purpose of the Data...

10
1 Scratching the Itch Jeff Parker, Merrimack College Scratch@MIT The primary purpose of the Data statement is to give names to constants; instead of referring to pi as 3.141592653589793 at every appearance, the variable Pi can be given that value with a Data statement and used instead of the longer form of the constant. This also simplifies modifying the program, should the value of pi change. Fortran manual for Xerox Computers

Transcript of 1 Scratching the Itch Jeff Parker, Merrimack College Scratch@MIT The primary purpose of the Data...

Page 1: 1 Scratching the Itch Jeff Parker, Merrimack College Scratch@MIT The primary purpose of the Data statement is to give names to constants; instead of referring.

1

Scratching the Itch

Jeff Parker, Merrimack College

Scratch@MITThe primary purpose of the Data statement is to give names to constants; instead of referring to pi as 3.141592653589793 at every appearance, the variable Pi can be given that value with a Data statement and used instead of the longer form of the constant. This also simplifies modifying the program, should the value of pi change.

Fortran manual for Xerox Computers

Page 2: 1 Scratching the Itch Jeff Parker, Merrimack College Scratch@MIT The primary purpose of the Data statement is to give names to constants; instead of referring.

2

OutlineSetting:

Teaching CS1 to students that didn't apply to MIT

Problem:

Hard for students to follow what a program is doing

Harder for students to write programs

It takes a long time to get to the good stuff

Course Goals:

Computers can do interesting things

Computers do only what you program them to do

Good News:

Scratch can help us teach these points and many other things

Bad news:

They need to move from Scratch to C++ or Java at some point

Page 3: 1 Scratching the Itch Jeff Parker, Merrimack College Scratch@MIT The primary purpose of the Data statement is to give names to constants; instead of referring.

3

What do we use Scratch to teach?We start CS1 with 2 weeks of Scratch

We cover

If Statements

If touching sprite2

Loops

Simple loops w/ observable events

Objects

Sprites have state (such as position) and behaviors

Plugability

Recursive nesting (see next slide)

Page 4: 1 Scratching the Itch Jeff Parker, Merrimack College Scratch@MIT The primary purpose of the Data statement is to give names to constants; instead of referring.

4

What do we use Scratch to teach?

Page 5: 1 Scratching the Itch Jeff Parker, Merrimack College Scratch@MIT The primary purpose of the Data statement is to give names to constants; instead of referring.

5

Difficulties

Equations are a difficult concept to grasp

Students do not understand equations

Heck, most adults don't understand equations

"Each equation in the book would halve the sales."

Stephen Hawking

Students do not understand assignment

Students have trouble with the notion of a variable

See the work of Dietmar Kuchemann and Zalman Usiskin

And variable in CS is different from a variable in Math

They really have trouble with notion of an indexed variable

Page 6: 1 Scratching the Itch Jeff Parker, Merrimack College Scratch@MIT The primary purpose of the Data statement is to give names to constants; instead of referring.

6

Simplicity of Model

There is (almost) no syntax in Scratch. Compare

Further, there is no loop index

for (int i = 0; i < 10; i++)

pop();

Page 7: 1 Scratching the Itch Jeff Parker, Merrimack College Scratch@MIT The primary purpose of the Data statement is to give names to constants; instead of referring.

7

ExamplesFocus on one issue: reading or writing a simple loop.

for (int i = ...; i < size; i++)

dest[i] = source[i]; // copy

if (a[i] > max) // Find maxmax = a[i];

a[i-1] = a[i]; // Shift left

fib[i] = fib[i-1] + fib[i-2] // fib

y[i]= y[i-1] + delta*fprime(x[i], y[i]) // Euler

if (s[i] != s[size - i - 1)// Palindromereturn NOT_PALINDROME

for (j = i; j < size - 1; j++) // Bubble Sortif (a[j] > a[j+1])

swap(a, j, j+1);

They have trouble thinking about the index

This doesn’t mean that they cannot understand these algorithms: it is expressing it formally that is difficult

Page 8: 1 Scratching the Itch Jeff Parker, Merrimack College Scratch@MIT The primary purpose of the Data statement is to give names to constants; instead of referring.

8

Simplicity of the Logo modelfor (t = 0; t < …) // Closed form expression

(x, y) = (x0 + t, y0 + 20 t – t2)

for (…) // Integration Model

x = x + ;

vy = vy – a;

y = y + vy;

for (…) // Logo Model

move(); // x = x + * cos(); y = y + * sin()

turn(); //

Page 9: 1 Scratching the Itch Jeff Parker, Merrimack College Scratch@MIT The primary purpose of the Data statement is to give names to constants; instead of referring.

9

Transition from Scratch to C++

Use the time with Scratch to cover algorithms

Introduce Single Stepping (Under Extras menu)

In the language of choice

Focus on programs with visible results

Relate new constructs to Scratch (see David Malan's talk)

They know the semantics: just need to learn syntax

Postpone subscripts (indexing) and equations

K & R – style Filters

LISP – style processing: car, cdr, cons

Still allows interesting projects such as Igpay Atinlay

Page 10: 1 Scratching the Itch Jeff Parker, Merrimack College Scratch@MIT The primary purpose of the Data statement is to give names to constants; instead of referring.

10

Transition from Scratch to C++

Preserve the community: let students learn from each other

Encourage students to work in pairs

Never say something a student can say

Foster a community of learners who listen to each other

Every student can do something right

Select their best work – you can still suggest changes

Make your examples ones you would share with colleagues

Take the time to explain a good algorithm, rather than introducing dumb example because it is simple

Keep it fun!