How should we teach programming?

Alfred Thompson’s Computer Science blog is on my daily read list.  It is always packed with useful discussions and great links.  Since I use Small Basic with my Programming I classes I was real excited to see a link to a couple of teachers that had written some material called Small Basic Recipes.  I was a bit stunned by what I found.  The two teachers had built a series of templates made of Small Basic program comments.  The students take these templates and build the code to fill in the comments.  The objective is to guide the students in the direction needed to write the code for a series of simple projects.  This comment template is so counter to everything I attempt to teach that the fact someone would go to the large amount of work required for this project totally shocked me.  Maybe the fact I am seeing this project out of the overall curriculum context makes it look like such a poor idea to me.  The templates are great, if all you want to do is teach kids how to write Small Basic code.  I, on the other hand, think writing the comments is the very basis of teaching and learning to program.  If you can write the comments correctly and clearly then the code should be a trivial exercise done by unimaginative people.  The comments are the key to teaching programming, not the code.  Given well written documentation and comments a programmer should be able to construct the code in their language of preference.  The first reading assignment I give my Programming I students is The Art of Code Documentation by Drew Sikora.  The article discusses the importance of documenting and commenting the code.  If I had the time I would love to design a semester around the concepts in this article.  I think a semester of writing documentation, comments and pseudo-code would the perfect way to start learning programming.  (I also think it would be as exciting as watching paint dry.  Banging out code and getting something to happen is just plain fun at times.)  I could care less if my programming students can generate code by the mega-line.  I want them to be able to take a project, break it down into manageable parts, visualize what needs to be done, and then write a series of comments that gives that visualization a foundation or framework.  In my opinion, programming is not typing code; it is designing something that can be adapted to code.  I do think there are some possibilities in the Small Basic Recipes as examples of the comments-to-code step and perhaps that is the intent when placed with-in the overall concept of their curriculum.  But as a stand-alone project I simply believe it is the absolute worst way to teach kids to program.

My comments here and the approach that Small Basic Recipes uses does bring up the question inquiring minds want to know – what are good pedagogies for teaching programming and what are bad ones?  Since there seems to be a major shortage of methods course for teaching programming in university Education departments (at least that I can find) it is a wonder we have any programming teachers with any consistent methods.  But that is a subject for a whole new blog.


4 Responses to “How should we teach programming?”

  1. Hélène Martin Says:

    I agree with you nearly entirely in that there’s not much interesting intellectual work involved in going from comments to code. That being said, in order for someone to be able to program, they have to be able to perform that step. It’s not entirely obvious — most languages have all kinds of nasty syntactic elements.

    I think these kinds of exercises, while not particularly meaningful in terms of problem-solving, are great for reducing cognitive load. Is it really fair to ask students to learn syntax, problem solving and any number of other things at the same time? Is it a reasonable way to expect mastery? I think there’s value to syntax drilling as students are getting started. This also lets them see what good commenting and design are like before doing it themselves. Again, does it make sense to throw students into innovating before they’ve really seen any code or algorithms?

    Overall, I agree these particular examples are unfortunate because there’s little interesting syntax involved in what they’re demonstrating but I can see the ‘recipe’ tactic as a useful one for syntax drilling and learning by example.

  2. Drew Sikora Says:

    “The first reading assignment I give my Programming I students is The Art of Code Documentation by Drew Sikora”

    Hey Garth, if that’s true I have a way better updated version I made for the Collection Beginning Programming book. Drop me an email and I’ll pass it on to you for your students!

  3. Alfred Thompson Says:

    I completely agree that we need a lot more research and discussion about what works and what doesn’t work in teaching. This is a tough problem that few seem to be attacking in a real and serious way.

  4. Garth Says:

    I guess what would make me nervous is if someone (most likely a beginning programming teacher) were to base their whole curriculum off of this recipes concept. I think Helene has a good point in reducing cognitive load. These recipes might even be fun for the kids, almost like a game. It also would give a demonstration of how good comments can make code development comparatively easy. A counter exercise could be going the other direction, given an uncommented program, write the comments. It seems I end up doing that a lot for programs I look at on the Small Basic site. That can really ratchet up the cognitive load.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: