# Teaching coding paradigms and concepts with specific context

Teaching programming is a great part of mentoring FRC (FIRST Robotics Competition) teams. For teaching how to program a robot (Specifically, a RoboRIO), I first (unintended pun: FIRST) need to teach various paradigms (OOP, Generics etc.). There is a need to find ways to teach necessary but general concepts before diving into programming the robot itself (e.g. motor controls and such).

Teaching Java paradigms in the classical and rather abstract sense usually confuses the students because they don't see any connection to robotics. As a result, students have difficulty understanding the subject (they aren't exactly at a level to learn that, so older team members try to teach it in a way that would make it easier). If they saw how these concepts integrated into programming the robot, then they would hopefully understand the subjects and their applications better.

So my question is this: how can I teach those programming concepts in the specific context of FIRST Robotics?

The students have a bit of experience with loops and types, but nothing more complex.

• This sounds a bit too general to be easy to answer. What part of this problem is really difficult, or different from what you're familiar with? – Sean Houlihane Jun 4 '17 at 9:49
• @SeanHoulihane edited to add that – ItamarG3 Jun 4 '17 at 10:41
• Thanks, Its a bit clearer now. Still seems a little like an X-Y problem meta.stackexchange.com/questions/66377/what-is-the-xy-problem but I think it's easy enough to answer. – Sean Houlihane Jun 4 '17 at 10:49

Based on my two years of involvement with FIRST, I have a few suggestions:

1. Teach students to read the documentation. This site covers Java programming for the 2017 FRC Control System. FIRST programming, while requiring general programming skills, is specialized for the roboRIO and for the competition as a whole. We ran into a couple issues this year whose solutions were found by methodically reading through these documents. There can be a rush to jump right to coding, but it is essential to understand the WPI library and its API fully. This also serves the purpose of seeing which programmers have the discipline to follow documentation to the letter. Having the patience and thought to do so is a necessary condition for being a successful programmer.

2. Use a simple chassis for coding/driving practice. Each year's game has its unique twists and challenges. However, underneath the superstructure is a drive base that in many cases can be used from year to year with slight modifications. Treat this as essentially a learning robot. Give it working code, let students drive it, then teach the code itself. Make changes from one run to the next. Since the code has immediate, real-world consequences, show the results of minor changes in action. This way you can then go back to the classroom/IDE knowing that students have a context in which to operate. Have them observe and reflect on what happens from run to run when one variable, say, is changed.

3. Research other teams' code. Most, maybe all, strong FRC programs have well-developed websites and numerous GitHub repositories. Look at best practices from these teams. Reach out to them. Have students try to read and understand their code.

Ultimately, students need to know Java, and understanding classes and objects, inheritance and polymorphism, will be as needed with FRC as anywhere else. However, to help them see how Java applies specifically to FRC, start with something that drives and work backward from there. Maybe start with #2, move back to #1, and lead them to #3, maybe even with examples you have found of how teams use the WPI library in different ways.

What I like to do is to first teach them the code that will actually make the robot move/do whatever it's supposed to do, then from that point I'd teach them the structures that can be used to make it more interesting.

For example, if the motor is represented by the DcMotor myMotor, I'd first go with the simple myMotor.setPower(1), just to get them to have a moment where they actually made it do something. From there, I'd add things like looping and I'd teach it the same way I'd teach it to other students, but here the thing being done might be checking the controller for changes in input to change the power for the motor.

Another route you could try (since the context is FIRST) is teaching myMotor.setPower first, then carrying on by explaining all the template code which surrounds it. The FIRST repo has a template of the code you can use, and explaining to students how it works could be a useful teaching tool.

I also disagree with your premise that "there is a need to find ways to teach necessary concepts before diving into programming the robot itself." As someone on a small FIRST Tech Challenge team, I was the first person who actually learned to code the robot. The way I learned was first by copy pasting things from the various templates provided and using Android Studios suggestions. From there, I found out about how to do various other concepts from the google.

• This isn't exactly what I meant in my question... but it does give me a better idea how teaching these things could be done, so thanks for that. Regarding the last paragraph: As mentors, we want to guide the students and teach them in a way that would be useful for them later. Students who learn these things on their own are more than welcome, but they are a minority. – ItamarG3 Jun 4 '17 at 10:58
• Oh whoops. What else would you like for me to try to address? – thesecretmaster Jun 4 '17 at 11:00
• "programming concepts be taught in relation to the context". Teaching the concepts through the robot programming. The idea is a way to teach programming concepts, with orientation to some context. – ItamarG3 Jun 4 '17 at 11:04