Does it matter when local variables are introduced? (For reference, HtDP refers to local variables in III.16.2 Local Definitions.)
One pro to waiting so long to introduce local definitions is that students are encouraged to think of "helper functions" that have a simple purpose. This is definitely a push toward good design habits. I am concerned that if I introduce local variables early, functions will balloon in size (ignoring the importance of having a "single responsibility").
One con is that they can have difficulty seeing the need for decomposing a problem with helper functions, and sometimes if the orgnization is incorrect it's difficult to complete.
The motivating example I have in mind is a function that places a dot at a random location on the screen, colored depending on the coordinates. Students that begin with (place-image ... (random WIDTH) (random HEIGHT) ...) are off track and have a hard time recovering.
There is a design process for this ("write and test a non-random version of the function first"), but like many things in teaching there needs to be a match between an approach and a student's level of receptivity to that approach.
I am curious about the thoughts of people experienced with either early local variables or avoiding local variables. What are the tradeoffs here?
Based on these 5 course table of contents(book included), we have:
Introduce map/filter/fold and then local (3)(the book, UWaterloo, Northeastern)
Introduce local and then map/filter/fold(2) (UBC, Indiana)
UBC 110 introduces local wayy later on, which is advantageous in that students can go backtrack to fix the classic performance problem of max-numbers(exponential blow up) not just once, but multiple times for binarytrees, mutual recursive types(modeling filesystem)
For my own course:
I recall I largely follow the books order in that I introduce map/filter/fold abstraction and then local because the two sections focused on reducing repetition(which was partially how I explained abstraction).
I was really tempted to follow UBC 110s route, but I didn't want to teach local wayyy after BSTs and Mutually Referential Data like they did because the earlier I introduce it, the quicker they can keep an eye on things to factor repetition out of and the more videos I can make showing the instinct of "ok, I typed this 2-4x now, I should probably store it"
As for the balance of delaying local so students get into a good habit of splitting up their tasks...
I try to rigorously enforce starting your work based off copying and pasting from the "function template" step of htdp, so I'm betting that they won't liter local everywhere because deriving the template itself has no local.
Also I'm more afraid of the opposite happening, that they'll use local way too little opposed to way too much if I introduce it very late, hence why I prefer introducing it at the half way point after map/filter/fold, so 50% of the rest of the course problems, they can practice thinking with local
I think your categorization is a little off because it doesn't consider enough things. The issue is how to order:
A. Abstraction and higher-order functions as a concept
B. Lexical scope (local)
C. The abstractions built-in to ISL (map etc)
D. Anonymous functions (lambda)
The book orders them A,C,B+D, which I think what Northeastern does. Indiana does A, B+D, C. UBC/Waterloo do B first, before A (I think).