Re: intro
[email protected] (Nathan Torkington)
| Newsgroups | perl.trainers |
|---|---|
| Message-ID | <[email protected]> |
Peter Scott writes:
> Can I have your students? :-) I do this, I also draw analogies with
> databases, talk about how a hash is like an array where you get to pick the
> indices, give them a cheat sheet showing the different types of basic
> operations on the primitives with examples, do examples on the computer in
> front of them... and still when they have an exercise involving traversing
> a hash some people sit there starting at the screen and eventually type
> something like @hash{$values} = keys @keys ...
Some suggestions:
- have them work in pairs. Often a student who grasps it can explain
it to ones that don't.
- have them "fill in the gaps" to complete code, starting with really
really really easy ones that they can copy from code already on the
page in front of them, then slowly build it up to complex stuff.
- calling them 'arrays' only leads to massive confusion. Call them
"hashes" and maintain that they're completely different from arrays,
otherwise they'll want to use [] and @ signs.
I wonder if flashcard-like drills might help here. It's nothing more
than a vocab problem they're having, and drills are the mainstay of
language education. The kind of thing where you show them
keys %age
and ask them to translate it ("returns a list of the keys from the
hash called age"). Go over them again and again until they've got
the answers memorized. Build up more and more complex expressions:
sort keys %age
foreach $name (sort keys %age) { ... }
You must be teaching rank beginners, because this is a problem that I
mainly find with people who haven't programmed before. Those of us
who have programmed before have a tokenizer inside us. The newbies
have to acquire that skill, and it isn't easy. It may not be possible
to teach this in a day to some people. They'll be forever unable to
decompose complex pieces of code into smaller ones they've seen before:
foreach VARIABLE (VALUES) { CODE }
sort LIST
keys HASH
Nat