Integrating coding into an existing class
How I teach students to code along with disciplinary material
This post is part of a series discussing incorporating coding into class where learning to code is not the sole purpose. So far I have discussed live coding as an instructional approach. You can find posts on why I use live coding, how to set up to live code, and the nuts and bolts of running a live coding class session, how to talk while live coding, and assessment strategies. This week I wanted to talk about how I design a course to include coding where that is not the main disciplinary focus.
What got me started teaching students to code as part of a hydrology course was curriculum design. If you’ve been faculty for a while, you’re probably familiar with this issue: here are the courses students must take to be considered an XYZ-ologist, and here are the courses they have to take to round out their college education—and the room for additions is precisely zero.
I was faced with this exact situation. I also saw the rising need for students to come out of college with some idea of how to write code. One solution to this—having students take a programming course in computer science—was a non-starter. In addition to the lack of room in the curriculum, it might not have been the best option for the students. Often, the skills built in general programming courses are not those most relevant to the data processing and analysis tasks that scientists typically use code to accomplish.
So, I decided the way forward was to teach students to code as part of a hydrology class. This is a challenging prospect. Time is already of the essence in any class. Things take longer than expected, and the list of “must-cover” topics seems to get smaller and smaller simply because teaching things well takes time. I’m not claiming I found a way to cover the same amount of material while also adding coding—but I have some thoughts on how to incorporate coding in a way that dovetails nicely with the class, rather than just having a standalone “how to code” unit.
Option 1: This is what I mostly do. I look at the topics I want to discuss in class and think about an analysis I could work through with the students to build understanding. For example, if the topic is runoff generation, I might come up with a few different hydrographs we could examine to discuss the role of various processes in a watershed. Then I consider how advanced the topic is and how advanced the coding skills needed for the activity are. Both of those factors help determine when the analysis will happen in class. If a foundational topic requires more advanced techniques, we might explore it another way—or I might give a “faded” activity, where students only need to modify parts of the code.
My Hydroinformatics online book is designed this way. I walk students through coding different analyses while also discussing what those analyses do and what they can tell us. A happy accident of this approach, I think, is that it slows down some of the introductory material. The section on basic statistics in my Hydroinformatics class initially felt too simple. However, it served the purpose of introducing some programming basics, like creating vectors and running simple functions. In early semesters, I was surprised to see discomfort with some aspects of these introductory statistics concepts—discomfort that was cleared up as we worked through things step by step.
I don’t think this is easy to do, and you might end up introducing fundamental coding concepts at the end of your course. For example, we don’t get to for loops until the last two weeks of my Hydroinformatics class, because they don’t become necessary until we reach modeling. (An aside: I kind of like this because it shows students you can do a lot without for loops.)
Option 2: If you have a lab session, I think that’s a great way to introduce programming. I’ve taught a class where the lab was essentially the programming component: the exercises were all data analysis. I’ve also had field-based labs where students then used code to generate plots and perform calculations for their lab reports. I think both are great options, depending on the course’s purpose!
I believe either of these approaches—mixed with a well-tuned live coding strategy that minimizes the chances of getting bogged down in technical issues—can help streamline the process of adding coding to your class, even if your students have little to no prior experience.