Sunday 26 October 2008

First stab at a chunk outline

This is my first stab at an outline. It will change! And it already includes unanswered questions. Interestingly, it is just about 500 words, or one fifth of the way there.

===========================
Prerequisites:

Students will have met primitive data types. Declarations. And have seen some simple scripts.

Focus on a large number of very compact examples.



Arrays
-Intro.
--The need to hold a number of similar pieces of data. Discussion examples - eg names, images in a slideshow, coordinates of lines, colours of pixels
--(Learn: purpose & utility of arrays)

-Example 1
--A simple example - create and access an array of names. Slow talk through. Then a program that displays them (no loop - hard code the array indexes).
--(Learn: recognise an array. Declare array. Access one element (get and set). Counting starts from zero)

--(initial example string vars - because simple in concept, don't have to struggle with abstract types. Don't use integers as I don't want any scope for confusion between index and value at this stage. Downside is that extra code is needed to create & load a font before I can display a string. And might end up being too machine dependent - does everyone have Arial?).


-Example 2
--Extend the example. One idea: Add a second array for colour values (for gold, silver & bronze). Mention that the first array of names was olympic medal winners. Step through array, displaying name in medal colour (or with a medal circle?). Second thoughts - just been playing; colours are tricky to get into at this time. I think the example looks too complex. Maybe better to have another of the same complexity as the first.
--(Learn: consolidate on previous)

-Some extras
--finding length of an array. Fixed size. More on counting from zero & implications.
--(learn: array.length, fixed size, obiwan errors)



For statements
-Intro
--The need to step through an array one item at a time. Discussion examples - big arrays where you can't hardcode.

-Example
--Take an earlier example & convert to an enumerated for loop

-Discussion
--Slow talk through the elements in the enumerated for loop

-Example
--Another stepping through array example - eg initialising a large array

-Discussion
--Not just for arrays. A for loop for any countable loop. More on varying the parts of the loop (eg the increment)

-Example
--A nice visual one, eg lines on a screen (different colours giving a gradient? Or splayed from a point, starburst-like?

-Another example
--Stepping through all the pixels in an image (but don't pre-empt chunk 21 too much!)

Deeper into arrays
-Multidimensional arrays
--Maybe review single-dimensional ones first? Stick to 2-dimensional, eg pixels.

-Example
--A nice big 2-dimensional array example, eg process squares in an image

-Array reference
--Array Functions - append() arrayCopy() concat() expand() reverse() shorten() sort() splice() subset()
--At least mention them, even if I don't cover them in detail.

More on For
-I suppose we should cover for..each loops. I have doubts whether this is the best place for them, but can't find them mentioned later in bookfragments. (I couldn't get one to iterate over an array - do for..each loops even exist in Processing?).

Wrap it up
-summary of learning points.
-A more complex (but colourful!) example to get them thinking.

No comments: