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:
- Assign lots of small problems
- Start with Parsonās Problems to focus on logic
- 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.