Reducing the number of concepts. To make teaching easier.

I am Sam.  Sam I am*.  Well at least my middle name is Sam.  So of course, one fun book I've always been drawn to is Green Eggs and Ham. The famous beginners book by "Dr. Seuss".
 
It contains just 50 different words: a, am, and, anywhere, are, be, boat, box, car, could, dark, do, eat, eggs, fox, goat, good, green, ham, here, house, I, if, in, let, like, may, me, mouse, not, on, or, rain, Sam, say, see, so, thank, that, the, them, there, they, train, tree, try, will, with, would, you.

A great beginners book, because it's a full story teaching a number of other concepts using a limited amount of words.  It's a clever bootstrapping hack to language learning.  Apart from all its cleverness, it's a fun & entertaining read too! :)

So you want to teach some newbies how to be l33t python pygame pr0grAmm3rs?  Maybe Sam I am, and Green Eggs and Ham have something to teach us, the teachers?

Let's reduce the number of concepts!

Classes, packages, and even functions are hard to get right away.  As in the first 10 minutes of teaching something to someone it's hard anyway.  Some people may get your car metaphors, and your nonsense about Ducks quacking like ducks... but others will look at you blankly.  Then that snotty nosed brat at the back of the class will start texting rude words about how you are a poo poo head, and it's GAME OVER.

However, there are two parts to these concepts.  Creating them, and just using them.

Here is an example pygame program using functions, packages, and classes... but not creating them.  This requires less knowledge to start doing something.

Press r for red.

import pygame
from pygame.locals import *

pygame.init()
screen = pygame.display.set_mode((640, 480))
message = "Press q to quit, b for blue, r for red."
pygame.display.set_caption(message)

going = True
while going:
    events = pygame.event.get()
    for event in events:
        print (event)
        if event.type == KEYDOWN and event.key == K_q:
            going = False
        if event.type == KEYDOWN and event.key == K_b:
            screen.fill(Color("blue"))
        if event.type == KEYDOWN and event.key == K_r:
            screen.fill(Color("red"))
      
    pygame.display.flip()


This displays quite a number of perhaps confusing concepts, but removes a few of the complex concepts.

Watch ALL the events printed out!

Notice how there are no functions declared, no classes created, and no packages declared.  There's also no "Reactor", or callbacks required for the events.  It's just importing (which is boiler plate).

Ask yourself, "How would I see all of the events coming into a browser with JavaScript?".  This example prints out all of the events happening to the program.  Including Keyboard events, and Mouse events.  You don't need to know in advance what type of events will be appearing.  You can discover that there is a key up event, that there are mouse motion events.

By reducing the set of concepts needed to understand the code you will have an easier job teaching it.

Press b for blue!


(* I don't like Green Eggs and Ham. I don't like them here or there. I don't like them anywhere.)

q for quit.

Comments

Unknown said…
It's also going to make your laptop hover 5cm over your desk by the sheer power of the fans trying to stop the CPU from combustion. *Please* add a clock, I know it's one concept more to understand, but it is important, and I'm sick of all those indie games draining my battery.

Popular posts from this blog

Draft 3 of, ^Let's write a unit test!^

Is PostgreSQL good enough?

post modern C tooling - draft 6