Making programming fun?
May 13, 2005 9:29 PM

Fun exercises to teach basic programming skills?

I'm going to be teaching an introductory programming course over the summer. I'd like the work that the students do to feel as interesting and meaningful as possible.

A lot of the textbooks I've reviewed are heavy on graphical applications. These are typically so scaffolded that the student does not do any interesting work. I'd rather have them build smaller projects that they can understand.

It will be in Java, although teaching good OO design is not necessarily the most important thing.
posted by shaun to Computers & Internet (18 answers total)
Word games (like an anagram generator or a "20 questions" tree) can be interesting and useful in teaching programming concepts.

Here's an idea: have your class create JSPs to generate simple web pages. HTML is another kind of wordplay, and the students would be able to create something visually interesting, perhaps even useful.
posted by SPrintF at 10:02 PM on May 13, 2005


I'd concentrate on teaching how to do general programing tasks over doing OO design. OO can be very useful but I wouldn't start there. It's hard to see why OO concepts are relevant if you don't have experience without them.

If you have extra time, make a lesson introducing changes into an existing small application and see how they react. Show them simple patterns that can make changing the app easier.
posted by rudyfink at 10:26 PM on May 13, 2005


Hmm, sorry. I was previewing and accidentally hit post before I was done.

Presentation and process applications are good places to start. Interactivity with users is also helps in teaching.

I'd recommend:
-Drawing/paint applicatoins
-Sound edit and transformation
-Messaging
-Web/Database interactions

I'd go with whatever is the most relevant to your students.
posted by rudyfink at 10:38 PM on May 13, 2005


While rudyfink's ideas are certainly good for students with some experience, for new students those are all relatively complex things. Drawing/paint rely on graphics APIs, sound editing & transformation requires pretty decent mathematical education, messaging is confusing with network programming and state... web/database interactions, depending on their complexity, would work, although I find that extremely boring, and not good for actually teaching programming.

My advice:
Don't do anything too dependent on APIs. APIs don't teach them programming, and are too prone to copying examples & changing parts until it works.

I enjoyed working through http://acm.uva.es/cgi-bin/OnlineJudge?Volume:1 (the first few, at least...). They're applicable in any language, and teach relatively good algorithm programming techniques.

Other than that, let them do what they want to do... everyone starts programming for a reason. Help them along on why they started.
posted by devilsbrigade at 12:21 AM on May 14, 2005


Gah, when they tried to teach us Java, they tried to make us do graphics and stuff first off to get us into the, uh, swing of things. (Pun bad, pun intended, I apologize profusely.)

What would've been useful for me would've been learning to deal with form elements and buttons. For instance, a "Yes/No" helpdesk question guide that took a user through a decision tree (Which also teaches tree logic, something that many programmers are surprisingly short on). Or, for an advanced project, learning to make a credit card processing application where you input an amount and then 'sign' using your mouse, which would teach both form, data processing and handling, and graphics. (And damn, if a student can show that off as a project to a potential employer ... they're hired. I mean, just sayin', as a programmer boss. It shows that they're thinking about how to apply those skills in ways I can use, as opposed to drawing pretty boxes on the screen because their teacher told them to.)

Personally, I learn best by being thrown off the deep end of an interesting project and being forced to come up with a way to solve it, with a little guidance. Saying "read chapter 5 and then create a program that draws a series of red boxes on the screen" does NOTHING for me ... saying, "The java docs are at java.sun.com. Learn to love them. You're going to be programming an application that actually does something.
posted by SpecialK at 2:05 AM on May 14, 2005


Get them to programme each other, in ordinary English, to do ordinary things, non-ordinary things. Then have them think about the ambiguities of ordinary language, and how they can tighten up the programme. Essentially, get them to construct a programming language for getting people to do things. Make them act out. This may sound stupid, but it actually works.
posted by TimothyMason at 2:08 AM on May 14, 2005


Oh, and by the way, the basis of this is used for Foreign Language Teaching. It's called TPR
posted by TimothyMason at 2:11 AM on May 14, 2005


Devilsbrigade has a good point. Maybe they already know what they want to do, and just need a bump in right direction. How about covering the basics in a week or two -- do "Hello, Cruel World" the first day so that they get some positive feedback and learn how to create programs on their own that will do things, and then go over the basics like "This is an if/else structure, this is a logic loop, this is a case tree," etc. in the next few days ... and then have a selection of projects that you've already researched that they can choose from at each point, with you providing progressively less input and fewer suggestions. For the final project, let them form groups and choose a project, give them a week, and you will provide guidance as to scope so that it fits into a week but not help them find resources or write the code.

The skills that you'll be teaching are therefore basic programming skills, research of prgramming functions, etc. (which is a vital skill ... knowing what an if/else loop looks like in Java is NOT but that's what most java classes I've taken have taught... :-P), completing and managing themselves on tasks and projects, and then working in a group on a project with a tight deadline. Those are three or four very important, directly applicable skills that can be put onto a resume verbatim.

Note that I'm assuming you're teaching this for a community college or vocational program as opposed to a university. If it's a university that has lesson plan requirements ... well, sorry, but you're probably stuck teaching colored boxes.
posted by SpecialK at 2:33 AM on May 14, 2005


You might want to take a look at Robocode from IBM. I had a bunch of fun turning loose a group of kids on it, and was very surprised at how much they learned and how deep they ended up getting. It is a Java based Robot fighting environment in which you program your robots by modifying or extending java classes. Unlike your request it is heavily OO based, however it is a very natural and fun way to learn it it my opinion.

I ended up turning it into a team based competition with very tight deadlines for the final project.
posted by tcskeptic at 6:08 AM on May 14, 2005


I took a Perl class where we did a "Shakespearean Insult Generator" - randomly selecting and concatenating phrases from pre-filled arrays - but depending on your audience, maybe a "Wu-Tang Name Generator" might be more appropriate. In any case, it might be a good exercise to teach some very basic skills such as arrays, strings, and control structures.
posted by matildaben at 6:14 AM on May 14, 2005


Simulating a vending machine that takes orders and makes change is a fun project. (Also fun to do in ROM for a hardware class.) It's an extensible project - there's room for growth in terms of graphic details, additional fulfillment algorithms, product prediction, stats tracking and analysis, and so forth.

Also, if you're doing ANYTHING related to the internet, please please please take the time to explain to them how the whole thing works - TCP/IP stack, routing, HTTP at the protocol level, how cookies work, etc...
posted by Caviar at 6:25 AM on May 14, 2005


Why not teach them to program web applications? Have them write Java servlets. You could even start with JSP. This has the virtue of giving instant gratification, being relevant to your students' previous experience with computers, being easy thanks to all the web development tools out there, and being actually relevant to something they may do in later life.
posted by Nelson at 10:10 AM on May 14, 2005


I'd like to second the suggestion for RoboCode.

Although there IS an API involved, you can spend each week focusing on a new construct, such as the for loop, if/else, while, etc.... It's great fun!
posted by furtive at 10:34 AM on May 14, 2005


I always thought writing a calculator was pretty fun.
posted by Mean Mr. Bucket at 10:44 AM on May 14, 2005


Depending on what you’re trying to teach, Processing may be useful. It will not be useful if you’re trying to teach them Java so they can immediately go out and get a job programming Java. But if you’re trying to teach programming, it gets rid of a lot of programming overheads (the ever-changing APIs, setting up build environments) and lets you do cool stuff right away. Plus, since it’s built on Java, you can deal with the APIs and build environments when you’re ready without having to learn another language.
posted by Gary at 10:53 AM on May 14, 2005


0. Really emphasize what they need to do to get a little build environment set up for themselves. Consider having them use ant and CVS (in a simple way) out of the gate. Have them write a little script that compiles their thing and then runs it if necessary. Have them write main()'s in various classes for testing. For projects, give them a list of API objects and methods they will need to use to give them a place to drill down. Have them use a debug/utility class in all their projects so they can write D.print("blah") instead of System.out.println("blah") and D.print(3) instead of System.out.println(Integer.toString(3))

1. Start them off with a basic server that listens for one connection and sends back "Hello, world!". Then have them change the app so it merely echoes back whatever is sent to it. Then have them change it to accept an arbitrary number of multiple connections. Then have them change it so what any client sends is passed to all other clients. Clients up to this point can be telnet, but then have them write applet clients that send serialized objects to each other.. maybe develop into a whiteboard applet.

2. Have them write a program to load a big dictionary file of words (e.g. /usr/share/dict/words). Tell them you want it to output the dictionary, but sorted by length of word first, then by another order. Lots of other things you can do, like hunt for palindromes, anagrams, telephone mnemonics, word completion in a single JTextBox, faux password-crackers...

3. Have them write a batch renamer for OS file stuff. Maybe introduce them to Regexp.

4. Have them write a Swing front-end to some native program that is execed. Like a calculator front-end to bc.

5. Have them do a really simple form, in Swing, with lots of fields, that reads in a template file and makes various substitutions, and writes out the merged file...

Some of these are really boring, but they might give the students ideas on how to write useful little programs for themselves.
posted by fleacircus at 12:48 PM on May 14, 2005


Simple games are something I would definitely reccomend. I remember doing breakout(aka alleyway) in my into Java class and zelda for my final project. Before that though maybe blackjack, poker, hearts, hangman, pong, stuff like that. Younger students especially will be much more motivated to work on an actual project that they can play with than forms and server crap which can be ugly.
posted by sophist at 6:15 PM on May 14, 2005


Robocode seems like a good tool.

Timothymason's point in talking about programs conversationally is really well taken. I've seen some amazing demonstrations of teaching programming concepts with some open space, stacks of cards (props), and a chalkboard.

I apologize if I implied undue complexity, but I think very simple apps can be coded in the examples I was talking about. I certainly wouldn't suggest putting students on a hunt for API calls or spending time building UI.

I was mainly trying to suggest doing examples in a framework where there is direct response in a context that is interesting to the student. The dangers that the response can distract from the concepts or that the time spent setting up of the "flashy response" will distract can be pretty small in very simple examples. I think the example can be kept simple or the complexity can be totally hidden with the result being an example with the benefit of keeping attention through involvement and "getting somewhere".
posted by rudyfink at 2:22 AM on May 15, 2005


« Older Need online database of record sales for...   |   I'm looking for old pictures of passenger pigeons... Newer »
This thread is closed to new comments.