Posts

Dr. Cay Horstmann: Three Key Insights for Teaching Programming

Dr. Cay Horstmann is a renowned computer science educator and the author of classic textbooks that have transformed the discipline, including Python for Everyone, Big Java: Late Objects and Big C++ Late Objects, all available in zyBook versions. 

In this interview, Dr. Horstmann shares three key insights for teaching programming that every computer science instructor should add to their pedagogical playbook. 

Let’s start with the challenges of teaching programming. What do you see? 

Dr. Horstmann  Computer science involves mastering a range of subjects, but what seems to be the biggest challenge for many students is programming. And I think the traditional teaching method, which often gives students four or five projects that last for several weeks, is simply not an effective approach to developing those coding skills. 

What happens? Students join what they like to call a “study group,” where one person usually writes the bulk of the code and the others don’t really learn very much. And then they move on to CS2. And you meet the CS2 instructor in the hallway and they’re livid. They want to know, how come the students finished a full semester of CS1 and they can’t program a simple loop? 

What’s an alternative approach? 

Dr. Horstmann What students really need to do, first and foremost, is practice coding in small chunks. Students learn by doing a lot of stuff, over and over. So literally, the way to teach loops is to make sure that students write 100 loops. And then the 101st one will not be all that hard. 

You can’t accomplish this with large, complex assignments. And I don’t believe that many students can learn the material by reading through the principles and applying them by the force of logic. They will figure it out simply by habit and by practice. 


Dr. Horstmann’s Tips for Teaching Programming: 

  1. Assign lots of small problems
  2. Start with Parson’s Problems to focus on logic
  3. Provide starter code to limit cognitive load

You’re talking about the power of short assignments.

Dr. Horstmann Yes. When they’ve done something a lot of times, the next time gets a little easier, and more automatic. 

When you start learning computer science, it’s totally brand new. There’s the programming environment, there’s the programming language with all of its weird exceptions and minor rules, and then there’s the problem you want to solve. Pretty soon you have cognitive overload. 

If you have to think about every little decision in the language, you won’t have enough brain cells left to also solve your problem. So there’s a lot to be said for making the simple parts routine – and that’s where these little exercises come in. Which is why our zyBooks versions are loaded with auto-graded formative questions and are so valuable. 

But look, if you really love your projects, you can still assign them! A few small projects can be very motivating because you can show students that they can do something that’s really exciting, even with the little programming they’ve learned up to that point. 

But what you also want to do is give your students ample opportunity to complete lots of simple, practice problems. And you know what? Students don’t seem to mind this. Because that practice is actually kind of rewarding – as long as what you ask them to do is simple and attainable.

That’s the really important part. The practice problems have to be something that takes them just a few minutes, and they get the instant reward of now having accomplished something that they previously had a hard time doing. That’s the power of small problems. 

What tools can you recommend to ease students into programming? 

Dr. Horstmann It’s really hard for students to get started with coding, so you want to avoid having them stare at a blank slate. That’s really frustrating. 

In our zyBooks, we avoid that pitfall by including what’s called Parson’s Problems, where students rearrange pre-formatted lines of code. This way, students don’t have to worry about getting bogged down with syntax and can focus solely on logic. I think of Parson’s Problems as a kind of icebreaker activity which I like to assign at the start of a course, so students can begin to think about logic and algorithms right away.

You also believe in giving students “starter code.” Why? 

Dr. Horstmann Another way to avoid the blank slate problem is to give your students some starter code to get them going. And it also reduces their cognitive load. In my experience, instructors don’t always appreciate this. They say, well, at some point, students are going to have to start from scratch. But that is not what I have ever experienced.

I can’t remember a single project in the last 30 years where I started from nothing. I have always had prior code that serves as a starting point, and developed the project from there. So I think starting from something and modifying it is very useful. It’s also more rewarding for students because they can focus on the one thing that they want to accomplish right now. 

Final thoughts? 

Dr. Horstmann The points I’m making are not limited to programming. I mean, in every type of instruction, the more you can get a student to practice effectively, the better, right? 

Lots of small problems, Parson’s Problems, starter code – they all make a difference. 


Dr. Horstmann on the benefits of teaching with zyBooks: