Document Sample
Scratch Powered By Docstoc

  Scratching the Itch

Jeff Parker, Merrimack College
       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

    Teaching CS1 to students that didn't apply to MIT
    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

What do we use Scratch to teach?
We start CS1 with 2 weeks of Scratch
We cover
  If Statements
      If touching sprite2
      Simple loops w/ observable events
      Sprites have state (such as position) and behaviors
      Recursive nesting (see next slide)

What do we use Scratch to teach?
An if statement has a condition
   A condition is a Boolean expression
        An expression can compare two integer expressions
           Integer expressions can be a number or a function
               Sample function: RNG, which uses expressions

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

            Simplicity of Model
There is (almost) no syntax in Scratch. Compare
   Further, there is no loop index

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

Focus on one issue: reading or writing a simple loop.
     for (int i = ...; i < size; i++)                     They have trouble
                                                          thinking about the index
         dest[i] = source[i];          // copy
                                                          This doesn’t mean that
         if (a[i] > max)               // Find max
                                                          they cannot understand
             max = a[i];
                                                          these algorithms: it is
         a[i-1] = a[i];                // Shift left      expressing it formally
                                                          that is difficult
         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)             // Palindrome
             return NOT_PALINDROME

         for (j = i; j < size - 1; j++) // Bubble Sort
             if (a[j] > a[j+1])
                  swap(a, j, j+1);

    Simplicity of the Logo model
for (t = 0; t < …)       // Closed form expression
    (x, y) = (x0 + D * t, y0 + 20 t – t2)

for (…)                // Integration Model
    x = x + D;
    vy = vy – a;
    y = y + vy;

for (…)                // Logo Model
    move(D);           // x = x + D * cos(q); y = y + D * sin(q)
    turn(f);           // q = q + f

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

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!

Shared By: