Be the ball
Crystal Furman wrote a nice post titled Coding Comprehension about a week ago. There was a little buzz about it in the APCS Facebook group and shortly after, Alfred Thompson added his two cents.
I thought I'd add mine, at least a couple of thoughts.
There are a lot of issues - long term retention, transfer of knowledge from the basics to more advanced tools, pattern recognition, and more.
It reminded me of Benjamin Zander's talk "Playing on one Buttock":
Check out the first five minutes.
Code reading is important, pair programming, where students are constantly explaining to each other helps, and there are other techniques.
We can also model thinking like a computer from day one.
Many of us start day one with exercises where students are the computer. Perhaps using a simplified made up language or maybe by just throwing some task at the kids and having them write instruction lists for each other. That's a great start, but we can continue drawing the relationship between the way we think and the way a computer works.
Take a simple intro problem – finding the largest value in a list of numbers.
The ultimate solution in Java might be:
public int findMax(int[] L){ maxIndex = 0; for (int i=0;i<L.length;i++){ if (a[i]<a[maxIndex]){ maxIndex = i; } } return maxIndex; }
Somewhere along the development process, I ask my students how they would find the largest value in list. If the list was short, they might just scan it. If the list was very long, they do the same thing as our Java snippet does - remember the largest so far as we scan down the list one by one. At first, we just think we're scanning the list, but if we slow things down, we see that we're following pretty much the same algorithm as what we'd write in code.
I use this technique throughout all my classes - slow ourselves down and really analyze the steps towards solving the problem. No single technique is going to teach our kids how to think about and comprehend code, but it's another tool in our bag of tricks.
Side note
This is my first post written using Emacs Org mode. I've been using it for years but only now discovering how amazing a tool it is.