To be honest, I wasn’t very satisfied with the way class my programming class went today. I’m understanding the material fairly well, but I felt like a lot of the students weren’t connecting with it. I think part of that is because they’re still trying to catch up on some of the earlier fundamentals in the course. The other part is I feel I was lecturing too much, and that I should have had them do more hands on activities today, but that would have been challenging too, given that a chunk of students are still trying to catch up on the basic concepts I just mentioned.
Today we reviewed some of the questions from last Monday’s exam, particularly those dealing with subroutines, bundles of computer code that can be reused by given them different inputs (for example add these three numbers, where the three numbers input into the program can change each time you run it. We looked at ways you can use a return keyword to take the results of these small programs and store them in containers of different types (i.e. simple variables like strings of characters, or more complicated variables like lists of items). We talked about how we can use our understanding of lists to process the inputs to these basic subroutine programs (i.e., by assigning list items to their own containers (variables) based on their position or by using foreach loops to perform activities like mathematical calculations on all of the inputs regardless of how many there are or in what order they’re input. We can also use these basic subroutines to print output onto the user’s screen.
We also discussed the idea of global vs. local containers (i.e., variables that can be accessed across multiple subroutine programs or vs. only accessible within a specific subroutine) and how using the keyword my can be useful here. I also explained how the Perl programming language handles global vs. local variables in different ways than more “modern” programming languages.
Programming at an elementary level is so difficult to teach, especially when the same terms are used for different things! Traditionally I have thought of a subroutine as inherently different than a function or method: I call a subroutine some specific repeatable block of code that takes some or no arguments and returns absolutely nothing. “Put these things in a database” or “Print this to the screen” are subroutines in my mind.
By contrast a function is something that has an output / return value, like Add(x,y) which returns the sum.
I usually don’t talk about global and local until I start talking about scope. I find that students have a hard time un-thinking that there is only global and local, when there are in fact different levels of scope even within individual functions (i.e. ‘with’ statements in java or ‘using’ statements in C#).
The hands on approach is definitely the best when it comes to programming, especially when you make it fun! Kelvin Sung at UW Bothell has some great intro level programming stuff using game development in XNA, you can find it over at microsoft.com/education/facultyconnection and searching for XNA.
Additionally, one of my colleagues, Alfred Thompson, has some great thoughts on teaching computer science. His blog is at http://blogs.msdn.com/b/alfredth. I hope that helps!
Dan
Thanks Dan for the prompt suggestions. I’ll think about these ideas and will check out the links you provided.