Friday, January 24, 2014

What Do Comedy and Coding Have in Common?

Timing. OK maybe not the most funny joke in the world but I’ve been dealing with time-managementtiming window problems in student programs all week long. A lot of my students in my Honors Programming course have been writing game programs for their semester projects. Some of them are using XNA which has been great. Their problems have been a different sort of interesting. But a number of students are writing Windows Forms programs and have discovered timers (mostly on their own) and using them to make things happen in a form of parallels. It’s been interesting.

On the one had setting up a timer and using it is pretty easy. On the other hand timers open the door to timing window problems especially if you use more them one of them. Frankly some kids have gone a bit overboard. Now it is not really their fault. And not really mine either. Timers were not something we talked about in any detail and timing window problems not at all. There is only so much one can cover in a single semester after all.

So what am I seeing? In some cases students are doing to much in a single event handler, or doing something that really shouldn’t be in there like open a message box, and the timer fires again before they are through. Crazy hard to debug loops quickly develop. Nothing quite like a hundred message boxes appearing in a few seconds.

In other cases they have multiple timers set at the same time and they step all over each other. Sometimes the students have trouble keeping track of which timers are set, which ones unset, and which ones accidently interfere with each other.

Having spent some time doing both networking and operating system development timing issues are far from foreign to me. Thank goodness for that! This is the first time I have seen students run into so many of them in the same class though. Debugging them has been interesting, entertaining and most of all educational for me. And I hope for them.

Threading and parallelism are  very important topics. They are becoming more so all the time as we move into the world of cloud computing and computing everywhere. While these used to be issues that affected only systems level programmers I can see this becoming something more and more developers have to deal with everyday. While most students will get some of these (sometimes a lot of it) at the university level we don’t see much of it at the secondary school level.

That is not to say that there are not tools that can help to some extent.image Alice has long had a Do Together command that causes several actions to happen in parallel. And threading options are available in many languages including the .Net languages (C# and Visual Basic) that I teach with. The actual use of many of these features though can get tricky quickly. I used to do some network programming with students that had tow executable on two systems communicating. Timing issues abounded as students struggled to make sure that messages did not come and go, or at least get handled, in the wrong order. It can be a lot for secondary school students.

The is no room in my one semester Honors Programming class. It is far too advanced for my Explorations in Computer Science class by a lot! No room in the APCS course either. I wish I had a post AP course where I could get into such advanced topics in the sort of detail they deserve. I think it would be fun.

For the time being I think I will spend a little bit of time with timers this semester (starts Monday) but not too much. I just want to cover some defensive tactics for those students who want to dig in deeper. Maybe make it less frustrating and more fun for them. And of course let them know just how deep and powerful threading and parallelism can be!

No comments:

Post a Comment