I’ve determined in my previous research that giving my introductory programming students a choice to program either a game or a real-life use project is the best way to go. This should counteract any gender bias.
However, I have noticed that when I introduce certain topics – such as functions or methods (some call them subroutines), students have a difficult time regardless of the project they have chosen.
What are functions? Functions require using logic that will cause the program to branch off to execute another set of blocked code. Most students begin to learn to program by placing all their code into the main function. At first, that’s acceptable, but as the program becomes more intricate, you need to be able to block your code to make it easily readable and fixable. It is agreeable that you think of the main function as a to-do list and let the functions do the work.
For example, you’ve been given the task to program a hangman game. You understand the rules of the game and you understand what you must to do to code the project, but your instructor has required you to use functions. Simply put, it’s just a different way to program! The outcome, whether or not the programmer uses functions, will be the same to the player of the game, but not to the programmer.
The question remains: How do you teach functions?
My director of our department sent this game to me last semester thinking it would be useful in my introduction to programming course to initiate the concept of functions and reusable code. I opened the link with a delighted surprise – it’s actually very fun to work with. Initially, I was concerned since most pre-programmed games I have come across have some juvenile aspect to it, but this game is just a bit different.
The name of the game is light-Bot developed by Coolio-Niato, sponsored by Armor Games on Kongregate. You program the robot to go through different obstacle courses. Eventually you run out of room with the commands, which forces you to begin using repeating code in functions. My students usually have a difficult time with functions in some manner and this game actually became fun for them.
I have to tell you as I was working through this again, my 12-year-old son couldn’t wait to give it a try. He actually did great!
You literally drag commands to the blocks in the order you want the robot to perform.
The site gives this description:
“light-Bot is a programming-style game version of Lego Mindstorms game. Give commands to your robot to light up the factory. Very soon you will realize though that using the main method on it's own is not enough and you will have to start creating re-usable functions to achieve the ultimate goal.”
Give it a quick try (it really only takes a moment!):
http://www.kongregate.com/games/Coolio_Niato/light-bot?email=invitation&referrer=
After level 6 (see image), you run out of spaces to drag commands and you are forced to watch for repeating code to put into your f1 and f2 slots. Then in the main function, you call the functions you have programmed.Before I introduced this to my class, I wanted to do some research to see if other studies have indicated any successes using games such as light-Bot. Guess what I found:
Developing Understanding of Programming Principles using Flash Actionscript
Graham Routledge, Amin Aminaei, Phillip Benachour
Department of Communication Systems
Infolab21, Lancaster University, UK
http://www.ics.heacademy.ac.uk/italics/vol6iss4/Routledgeetal.pdf
The authors’ noted, “It is important as a result to find ways of engaging students in activities where programming is seen as a tool to demonstrate other concepts and ideas visually which can in turn help in the teaching of programming principles.”
The concepts and methods used when writing programming code can seem very abstract and difficult to understand. How can you program something you don’t understand?
The authors concluded that for many students entering higher education to study information and media technology with no or little programming experience, it is not always obvious what a ‘function’ is or how an ‘if’, or ‘else if’ statement or an ‘array’ works and where it should be used.
Also, In general, basic programming should not be too difficult for beginners, but concepts can be difficult to visualize for some students, while for others the written example code alone is enough to build a mental image of what is happening within the program and this often leads to varying learning rates for different students.
In conclusion, the authors’ stated, “When evaluating student feedback, the results show that a majority of students –with and without previous programming experience- will engage well with an application environment where visualisation is involved. A high majority of students with previous programming experience (82%) said that they felt that learning to program without visualisation was hard and slowed their progress.”
My Thoughts
I didn’t introduce light-Bot to my class right away. I really wanted them to learn syntax – that is C++ code – before getting “lazy” by dragging commands. We had been burned by using Alice before, so I was hesitant to use this immediately.
However, when time came around for repeating code and the introduction of functions, I introduced them to this game. Again, it doesn’t take very long before you are forced to use functions – which helps the students understand the concept of repeating code and how smaller functions can be reused over and over.
The good part of this is that the students “get” exactly what is happening when a call to a function is added to their program. That’s half the battle! In fact, when it came time to write their program, they understood exactly what types of functions to use and where to put them.
The not-so-good part of this is that while the students began to see the usefulness of functions, they had a tough time getting functions to behave using the C++ syntax. Pass by reference or pass by value? Does the order of the arguments matter? Regardless, that’s another issue for another post.
In light-Bots, you also don’t pass parameters or use arguments in these functions, but the whole idea is just getting the students to recognize the value of reusable code.
Once you’ve done that – you’re on your way!
Tell me what you think of light-Bots. I’d love to hear your thoughts and results.
References:
Kongregate, “Play light-Bot”, Web Site: http://www.kongregate.com/games/Coolio_Niato/light-bot?email=invitation&referrer=
Routledge, G., Aminaei, A., Benachour, P. (October 2007). “Developing Understanding of Programming Principles using Flash Actionscript”, Retrieved: April 19, 2009. Web Site: http://www.ics.heacademy.ac.uk/italics/vol6iss4/Routledgeetal.pdf

