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
... 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
Comments
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
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
Now introduce data going IN to the sub program. Still super simple examples here (adding two numbers etc).
#TeamCompSci #CASchat #CSed #CSK8 #CSScot
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
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
Great thread Andy.
https://en.m.wikipedia.org/wiki/Separation_of_concerns
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