Teaching logical thinking

I knew that Computer Science and logic were closely tied together, but I’ve been surprised by how difficult that logical thinking comes to my students.  I can’t remember if I’ve mentioned this before, but I have to say my writing background is perfectly suited to CS.  Writing = Logical Thinking.  When I started doing some programming several years ago, I struggled mostly with syntax, but once I switched to a language with a more logical syntax, a lot of the thought process of programming came naturally.

My students, though, are struggling a bit, at times.  We’re working right now on just using functions, loops, variables and some simple calculations.  We start using some boolean logic next class period.  It takes them quite a bit just to wrap their heads around calling functions and using variables (instead of putting in actual numbers). Calling a function within a function totally blows their minds.  I think the issue is a difference between concrete and abstract thinking (as well as logic).  So, for example, they’ve been writing programs one line at a time in a “do this”, “do this”, and then “do this.” kind of fashion and not thinking, okay, I’m doing this 3 times, maybe I should use a loop.  Or I’m having to calculate this by hand every time, why don’t I write a function I can reuse over and over again.

My plan for next class period is to take their existing programs and rewrite them to both take advantage of abstraction and to include some boolean logic.    I’m just going to keep repeating and going over these things until it sinks in.

For Halloween, I wrote a little program to do this:



Not the most exciting thing, but all done with (gasp) math and programming.