11/n Shortcuts
Now you can start to 'reveal' the magic hacks/shortcuts. Call one sub from within another. Use a returned value as an argument for a different sub. Calling from a print or as part of a calculation. Let them create from solid foundations
Fin
#TeamCompSci #CASchat #CSed #CSK8 #CSScot
10/n Functions with parameters
Data going in and out of the sub program. Now we can make our calculator useful. I teach to get user input in the main then send the arguments to the subs, which do the calc and return the answer into a variable in the main.
#TeamCompSci #CASchat #CSed #CSK8 #CSScot
9/n - Functions with no parameters
Next, return values. Hard coded calculations that return the value back to the main program. I teach to ALWAYS assign the return value to a variable (one thing per line) for use in the main program. No parameters yet.
#TeamCompSci #CASchat #CSed #CSK8 #CSScot
8/n - Procedures with parameters and arguments
Now introduce data going IN to the sub program. Still super simple examples here (adding two numbers etc).
#TeamCompSci #CASchat #CSed #CSK8 #CSScot
7/n - Procedures first (NO parameters yet)
Just procedures first. Let students practice defining, calling and the new flow of a modular program without the extra load of parameters and return values.
#TeamCompSci #CASchat #CSed #CSK8 #CSScot
6/n - One thing per line
Just like with all my teaching, I go the long way round. Make your examples do one 'thing' per line as much as poss - no function calls print statements etc. Reducing the syntactic density of each line really helps new learners.
#TeamCompSci #CASchat #CSed #CSK8 #CSScot
5b/n
... they ARE right (for the moment). Explain that you've simplified the subs because you want them to just practice defining and calling. This does seem overly complex, but makes the a MUCH better CS thinker & programmer with bigger tasks later.
#TeamCompSci #CASchat #CSed #CSK8 #CSScot
5a/n - It will seem pointless at first, and that's fine
If you've followed step 4 then some students will probably ask you why they just can't write a sequential program - that's a much simpler way of achieving the same result right?
#TeamCompSci #CASchat #CSed #CSK8 #CSScot
4/n - Super simple subs
Your subs shouldn't do anything especially complex (and DEFINITELY no new skills) for a while. Just getting used to defining and calling is plenty for the working memory to be getting on with.
Simple outputs/calculations at first.
#TeamCompSci #CASchat #CSed #CSK8 #CSScot
3/n - Language
Be super careful about your language. Call them sub-programs/subroutines or whatever fits your curriculum. BUT - procedures and functions are TYPES of sub-program and should be introduced as such.
#TeamCompSci #CASchat #CSed #CSK8 #CSScot
2/n - When to teach
I introduce them just after teaching about decomposition so they fit in with what students have just learned. Up to then I have taught the basic programming skills/structures of output, input, variables, selection & iteration
#TeamCompSci #CASchat #CSed #CSK8 #CSScot
1/n
Thread: Managing cognitive load when introducing sub-programs.
Had a great discussion with @httcs.online (PS - ooh nice handle!) about this the other day. Here's my suggested approach.
#TeamCompSci #CASchat #CSed #CSK8 #CSScot
Does adding data to a USB flash drive make it heavier? A great fertile question for data rep & storage lessons. Here's always excellent @fryrsquared.bsky.social with another brilliant explanation. #TeamCompSci #CASchat #CSed #CSscot
www.instagram.com/reel/DDcU-1M...