Thursday, 18 May 2017

Getting Started: Introduce Coding Using Swift Playgrounds on iPad

Swift Playgrounds is an application for the iPad built by Apple to help developers learn how to write Swift applications.
Swift Playgrounds is a revolutionary new app for iPad that makes learning Swift interactive and fun. Solve puzzles to master the basics using Swift — a powerful programming language created by Apple and used by the pros to build many of today’s most popular apps. [https://www.apple.com/uk/swift/playgrounds/]
Although the application is designed primarily for developers, it can also be used to help engage children in coding. For younger children, this does require adult supervision to help with explaining what the function does.

The session is designed for younger coders, for children aged 6 and upward it might be better to try the Hour of Code session created by Apple.

Getting Started

Session Time


Around 30 minutes

What you need


  • An iPad, probably Air 2 or newer. The graphics that render are quite cool, but require some power. I haven't tried it on an older device, but it seems fine on the Air 2
  • Download Swift Playgrounds from the Apple App Store
  • Download Learn to Code 1 as an in App download form the Swift Playgrounds app

Preparation 

  • It is worthwhile taking a look around the app and getting familiar with how it works. You don't really need any significant programming experience. The session will focus on moving an alien around the screen to pick up gems and activate switches
  • For younger children the trainer will need to help with reading skills and choosing the correct function. The functions are moveForward(), turnLeft(), collectGem(), toggleSwitch(). If you haven't come across the term function before, just think of it as an action the alien will perform
  • This session is really just a game, there's no programming loops just yet. These are for a different session
  • You will probably find you can run this same session many times, children really like the interaction and ease of controlling the alien

Controls & Leading Play

  • Controls are as simple as pressing the name of the functions (actions) that you need. To go forward twice pick the moveForward() function twice. Think of it like playing a step-by-step platform game
  • If the child says they're not sure what's next just run the program. The alien finishes up at the last instruction and then you can correct. Allow the child to make mistakes, this is really important and it's OK to not have the correct solution first time. They'll struggle later if this isn't done right from the beginning as the problems become more complex
  • Let them hold the iPad and control the pressing. You might want to have a small session where you show them first, but they will get more from being the one pressing the buttons


The screen has a description and extra instructions of what needs to be done. The code is the list of instructions at the bottom left. Run my code/stop is at the bottom of the screen. 

Lessons to Try

For a thirty minute session the following are probably enough to get started. I've also outlined some things to discuss and think about each lesson and a sample solution.

  • Issuing Commands
  • Adding a New Command
  • Toggling a Switch
  • Portal Practice
  • Finding and Fixing Bugs
  • Bug Squash Practice
  • The Shortest Route
Below are some sample solutions that we came up with:

In the next lesson we will look at how to make use of the Functions module and how to use that for teaching. 

Friday, 12 May 2017

Kids Code Introduction

In recent years my blog has been fairly empty, life in general has taken over most of my free time. We have two small children aged 4 and 7 months, who are hard work but a lot of fun. The way in which children interact with technology fascinates me, Emily is quicker at using the iPad than her grandparents! Inspired by Devoxx UK, I have decided to try get back into community work. 

For the last three years I have taught over 500 developers fresh from University how to code better and prepare for a career that is more than just hacking they may have done at Uni. Most of the trainees have significant experience coding and the rest have at least started their journey. Often friends who don't program ask "How do I get into coding" or "How would I got about writing an app". It's very difficult to explain what coding is to an adult, so how do you get this across to a child that is just learning to read and write?



The are many educational games and activities targeting children, particularly for basic math and letters. Seeing how excited my daughter got by playing these games it inspired me to look at ways I could teach her the basics of programming. I wanted it to be something that we could do interactively together and that she also enjoyed spending time on. Making things fun is important, regardless of age group. An engaged trainee that is following a narrative or story along with hands on experience is usually the most successful in retaining information. 

In the blog posts to follow I'll be writing about the mini-training session plans I am working on with Emily (4 years old). Like any good training there should be some objectives and an understanding of the trainee:
  • Make coding and thinking in a structured way appealing to children. The goal here is not for Emily to join a start-up or to get to 10 and be a computer genius. It's adding an extra layer of thinking and approach to problems that schools are just getting to grips with. 
  • Sessions are no more than 30 minutes, anything longer and a young child may resent the task. I've found that it's also OK if they want to go and do something else, just start the session again from the beginning (if they remember they'll usually tell you). 
  • Being able to read is not necessary, but will help. We started this process before Emily could read, and now she can recognise some letters. We work together on choosing the right function calls and code as we go. Initially I drove that, but now she is much more confident in choosing the right functions.
  • Is not always on a computer. Some of the sessions that I am planning are not on the computer at all, but will have tasks that related to designing and executing instructions. 
Below is a video from one of my first training sessions with Emily. We are using software on the iPad called Swift Playgrounds, which is designed to teach developers how to learn Swift. However some of the early content can be used to also teach children basic concepts in a fun game environment. This will be the subject of the first lesson plan that I will publish next week. This video is special to me personally as it shows that coding can be fun and rewarding, even from a young age. 


If you are interested in following the lesson plans please keep an eye on my Kids Code page for links and on twitter. Also please do comment or make suggestions, I hope you have as much fun as we are having.