Get Off Your Butt and Teach Your Kids to Code

Saturday, December 8, 2018

If you're my age (born in the early 1980s) and know how to code, then it has likely been a differentiator for you in your career. I can't think of a single thing I've done professionally where my ability to understand programming concepts and write code has not benefited me in some way. However, coding is fast becoming a more common skill set amongst the younger generations. Teaching our kids to code is now more of a necessity and less of a luxury.

Today was the start of Snowmageddon 2018 (not really, this is SC and there might be some freezing rain). It was cold and wet outside and everyone was holed up indoors. Kids were restless and parents were on edge. I was getting some prep work done for a class I'm teaching next week when my four year old daughter walked in, picked up a box, and placed it on my head. I immediately felt like a robot and started making robot sounds and noises. Then it hit me... The ideas rushed in and before I could get in another beep-boop, I had put together a progressive plan for teaching my kids to code using me as a robot.

Normally I wouldn't write about something like this, but it worked out so well that I wanted to share it in hopes that not only would it give parents an interesting way to teach code, but also get them off their butts and interacting with their children in a more physical way as opposed to sitting in front of a computer or TV screen.

So here's how it unfolded.

As the robot, I got to be as flexible or rigid with following the commands as the child needed for their ability level. I also got to make up funny responses on the fly to bad commands that I knew would fail, and commands that ended badly by running into furniture and stubbing my toes on door jams. Don't let me downplay the importance of actually having a box for a robot head. With no eye holes I might add. It kept me honest, and gave the kids another reason to be creative. My ten year old went as far as to draw a face on it for me and name me. I can't remember what she named me because my wife quickly changed the name to "Pain in the Bot" and it stuck.

Level 1 was very simple. Even my four year old could do this. I gave the kids a very simple task that involved moving about the house i.e. "get me from my desk chair to the bathroom". All commands were given verbally. The children took turns and I followed the commands exactly. I gave very little coaching at this level and just let them get use to giving me commands and discovering how I would respond. Most commands were something like "10 steps forward" and "turn left". Nothing too complex.

Level 2 was also verbal, but I ramped up the complexity and coaching. The command "10 steps forward" signifies a looping construct, so I began coaching them to say stuff like, "count from 1 to 10 and take a step on each count". I also introduced them to conditions. I coached them into commands like "until the floor is hard, take steps" which would cause me to walk across the carpet until I hit the hardwood floor. Another example would be "until in the kitchen, take steps" which would cause me to walk through the living room until I hit the other side of the kitchen threshold. The kids started using degrees of turns as well instead of simple "left" and "right" commands.

Level 3 is where things really got fun. Rather than follow commands one at a time, I gave the children a simple task and had them begin to plan on their own using paper, building a list commands they thought would get the task done. At this time they had a decent understanding of the syntax I'd been using and the available commands and constructs. Once they had a "script" built, I took the script and followed it exactly. Like all code, it never compiled or executed perfectly the first time. There were bugs. Spelling errors caused me to not understand a command. I didn't take enough steps and ended up facing a wall, unable to continue. I tripped over some obstruction in the way that they didn't account for and it threw me off track. When these kinds of things happened, I would let them debug, modify the code, and start execution all over again when they were ready. We did this until the task was complete.

This is where we left off. It was a ton of fun, took a good bit of time, and everyone walked away unscathed... except for a few bruises and broken toes (I was dedicated to the part). I will eventually parlay this into something more closely tied to computer programming, but this was a great way to introduce my children to programming concepts, even though they have no idea that's what they were doing.

I'd love to hear some feedback on this. Especially if you have ideas on ways to make it better, or other examples of ways to introduce more complex constructs like functions, etc. Let me know what you come up with!

Like what you see? Join me for live training! See the Training page for more information.

Please share your thoughts, comments, and suggestions via Twitter.