Talks

Test-First Teaching

Test-First Teaching

by Sarah Allen and Alex Chaffee

In the video titled "Test-First Teaching," speakers Sarah Allen and Alex Chaffee discuss an innovative technique for teaching programming, primarily focusing on Ruby. The talk highlights how writing tests before coding can be a highly effective way to learn programming concepts systematically.

Key Points Discussed:
- The Concept of Test-First Teaching: This method involves giving students micro-tests to pass, helping them learn programming concepts incrementally. It encourages learning one test at a time in various settings, including classrooms and informal environments.
- Benefits of Teaching Through Testing: Teaching and creating tests can enhance understanding for both teachers and students. It creates a collaborative learning atmosphere where students can engage actively with the material.
- Comparison with Traditional Methods: Traditional classes often leave students bored with static texts and lengthy lectures. Test-first teaching engages students by immersing them in coding exercises from the start, fostering a more interactive and enjoyable learning experience.
- Effective Collaboration: Pair programming is encouraged, where students learn together, enhancing confidence and understanding. The method of teaching through micro-tests allows for individual mastery alongside collaborative learning.
- Independent Development of the Method: Many educators, ranging from Mike Clark to Yehuda Katz, have independently developed similar methods of teaching coding through tests, confirming its effectiveness as evidenced by positive student evaluations.
- Use of Engaging Materials: Resources like Ruby Koans demonstrate interactive testing concepts, while the open-source site, testfirst.org, provides substantial curriculum materials for Ruby educators and students alike.
- Learning through Failure: Students are taught to embrace failure as part of the learning process, which is critical for growth in programming. Real-world mistakes encountered during testing help build resilience.
- Practical Applications: Examples provided include creating simple projects like calculators or a Pig Latin translator in Ruby, illustrating fundamental programming concepts engagingly.

Conclusion: The goal of test-first teaching is to provide meaningful learning experiences grounded in practical applications of programming. This method encourages interaction, collaboration, and resilience in students, ultimately empowering them to develop lasting programming skills. The session invites educators to explore and contribute to the growing body of resources aimed at enhancing programming education.

00:00:05.120 I want to start by asking who here has taught in a classroom setting or a group setting where you've taught a group of people? Wow, a lot of people! How many of you use tests? Okay, great crowd! And who here has taught in an informal setting? Alright!
00:00:20.800 So we're going to talk about test-first teaching, which is a specific technique for teaching programming. This approach is not unique to Ruby, but we'll mostly focus on the Ruby efforts.
00:00:30.320 So why should you care about this? Maybe you want to learn Ruby better than you already know, or you're a novice coming to this conference wanting to learn Ruby at all. Perhaps you have a friend or colleague you want to teach, or a relative who's always wanted to learn to program. Or maybe you're a teacher and you want to help improve our materials or participate in using them.
00:00:55.040 You may also recognize that the act of teaching helps you learn. In fact, even if you're not an active teacher, everybody who participates in engineering and the kind of teaching we do finds that the best engineers are often great teachers.
00:01:06.880 We work collaboratively, and we live in an environment where it's not sufficient to know any one thing well; you always have to acquire that next new thing. You produce great software if you're constantly teaching what you know and then working with people who let you learn.
00:01:19.680 I was impressed by Jim's comment in the last talk. He said that he worked through the exercises but hadn't taught them yet, so he didn't really understand them. This captures a feeling that many of us share: we often don't fully understand a concept until we've taught it or even created a course about it.
00:01:30.720 So, what is test-first teaching? This is the idea that the teacher provides micro-tests and the student works to make them pass. By doing this, students learn concepts one test at a time. This can be done in a classroom setting, guided, solo, or in a pairing situation.
00:01:44.000 This method is different from test-driven development, which we'll talk about later. Pairing involves teaching collaboratively; you teach each other. We are also enthusiastic about pairing in the classroom.
00:02:01.440 When I started teaching Ruby, I would encourage people to pair, but some felt they really needed to work on their own to master the skills. Both methods can work effectively. In pairing, students often teach each other, which is beneficial.
00:02:14.560 Doing exercises together helps students through the rough spots without constantly asking for help, allowing the teacher to move around the room and assist with more challenging questions. This form of collaboration enhances the learning process and builds students' self-esteem.
00:02:35.040 So how do we know this approach is effective? It turns out that there are many independent inventors of this method. When I first started teaching Ruby, I was signed up to teach a Ruby on Rails class and strongly believed in the importance of teaching testing. However, I was met with resistance from others who said it would frustrate students.
00:02:54.560 I took their concerns to heart, but then I tweeted about it, and Alex, whom I had met once, tweeted back in support of teaching testing. We started a partnership born from this shared enthusiasm for better teaching methods.
00:03:11.680 Alex created a curriculum in Java in 2002. In doing research for this talk, we discovered that many different educators realized that teaching coding through tests is an effective way to learn. For instance, in 2005, Mike Clark wrote about using Ruby to learn through tests.
00:03:29.440 Later, Art Howard's Ruby Quiz and other initiatives contributed to this approach. I spoke with Yehuda Katz, who mentioned he'd been teaching in a similar fashion using this technique for Ruby on Rails training.
00:03:43.680 So when I came to this realization, it wasn't clear that it would be a good teaching method, though it certainly turned out to be effective. Many people independently developed this method. We know it's a valuable approach because it works, as indicated by student evaluations.
00:04:03.760 Students have expressed that homework can be enjoyable, which is quite unexpected for them. They want more and are eager to learn more advanced concepts, like threads, even if it means they can't apply everything right away.
00:04:20.000 To give you some background, we're going to quickly cover our test-first teaching materials. Test-first teaching is something that Sarah and I have developed together. It involves Ruby and micro-tests, positioned at a conceptual level that allows students to tackle more significant lessons.
00:04:29.760 In contrast, methodologies like Ruby Koans focus on more incremental learning about the language. I'll provide code examples and discuss these two teaching styles further.
00:04:41.760 Ruby Koans is particularly engaging. Many people here might have participated in Ruby Quiz number 67, which is a fun and instructive challenge that teaches programming concepts through test-driven learning.
00:05:02.640 If you are interested in learning Ruby at an advanced level, there's a relatively recent book titled 'Growing Object-Oriented Software,' which is being adapted for Ruby by Brian Merrick.
00:05:20.800 Our site, testfirst.org, aims to provide materials for both students and teachers. It is meant to be open-source, so we welcome contributions from anyone interested in helping out.
00:05:39.600 We've recruited contributors, like Leah, who joined us early on and has been a vital part of developing our materials. This initiative is about creating an inclusive learning experience for all.
00:05:58.560 Typically, in traditional programming classes, students appear bored. However, I appreciate how engaged you all seem today! Commonly, courses consist of static texts printed and handed out to students before a class, followed by lengthy lectures.
00:06:12.080 But it's not the lecture that ultimately hinders progress—the exercises often fail to truly engage students. They can be overly simplistic, like multiple-choice questions, or too complicated, requiring students to fill in the blanks on incomplete code.
00:06:26.080 Many students find themselves stuck, unable to confidently complete these tasks, leading to frustration during lessons.
00:06:41.760 It's far better to engage students in active coding straight away. This structured approach helps students understand what they need to achieve without feeling overwhelmed.
00:06:54.760 Ultimately, we want to encourage a learning atmosphere where engaging with code is fun and rewarding. This approach can be powerful in stimulating students to explore deeper.
00:07:07.440 A major element of test-first teaching involves not fearing failure. Students must learn that encountering errors is part of the learning journey, allowing them to develop resilience.
00:07:23.440 By experiencing failure in a structured manner, such as through broken tests, students encounter challenges similar to those they will face in the wild. This exposure to real-world mistakes is critical in their growth as programmers.
00:07:41.279 Lasting learning occurs when students feel comfortable, engaged, and playful during the process. Therefore, acknowledging and embracing the initial struggles of learning programming is essential.
00:07:55.440 In addition to test-driven exercises, numerous teaching strategies contribute to effective instruction. A thorough understanding of these approaches is vital for any educator.
00:08:10.240 We welcome you to explore our teaching resources, which help us establish connections with various programming concepts. By doing this, we can facilitate intuitive learning experiences.
00:08:47.840 Let's examine a basic programming example: creating a simple calculator in Ruby. Students will begin with the instruction to add zero plus zero and eventually develop and test the class to function correctly.
00:09:03.120 As students test their code, they might encounter multiple failures, pushing them to refine their understanding of Ruby functionality. This reflection on errors helps reinforce the learning process.
00:09:18.560 In the rubric of our teaching methods, connecting practical exercises to fundamental concepts allows students to appreciate how programming works. For example, in a lesson about strings, we might engage students in building a Pig Latin translator.
00:09:43.040 Understanding the concept and mechanics of Pig Latin can be quite engaging and relevant as it touches on string manipulation in Ruby in an enjoyable way. By making this connection, we help lower the barrier to learning programming.
00:10:07.440 These lessons not only reinforce the concepts we want to teach but also highlight the creativity involved in programming as students develop their own solutions.
00:10:28.640 In closing, the goal of test-first teaching is to ground programming skills in practical, relevant lessons. It's about quality learning experiences that empower students to engage with the code and develop lasting skills.
00:10:43.120 I’d like to thank you all for your time. If you have any questions or would like to discuss further, Sarah and I would be happy to engage with you after the session!