Welcome to my Programming Blog...

I am currently working on a couple of projects: An original game called "Implosion" which I am porting from Flash to the iPad, and a remake of Q*bert in Python (pygame), as part of the class I am teaching. Please feel free to use the "Labels" (at right) to follow a specific project or theme. If you are one of my Python students, I recommend that you check out the Python thread.

Tuesday, September 14, 2010

For want of a nail...

"Hubris!" a friend of mine exclaimed as he watched the pomp and circumstance of a recent pep rally at our school as we prepared to face a team better prepared than our previous opponents. "Hubris!"

I mention this, because I was congratulating myself on how clean my code was. When I wanted to add a new feature - hints for the player who is stuck - it was a relatively easy addition to make because my code was broken down well and documented. "Hubris!"

As you might guess, I've been hunting a bug, and finding others along the way...

The bug I was after was one that was causing the program to freeze and crash whenever the chips needed to disappear from the back of the screen. I had just been adding in the hints code and was in the process of fixing a glitch where some pieces wouldn't stop spinning. I looked all over the game manager code where I had been working, ran the debugger to isolate the line, checked and double-checked the memory management code, even ran instruments!

I found two tiny memory leaks in Instruments, but they didn't fix my bug. Finally, after the better part of a week of searching, I found it tonight. It was a change inside the Chip class, where I had been modifying the "description" method to add one mo piece of information - and pit the new code outside of the square brackets. Somehow, it escaped the debugger, and caused me nightmares.

Once that tiny line was repaired the problem went away, and I was able to fix my unstoppable spinning chips in no time at all. Fixing the leaks seems to have made some memory warnings go away, as well!

Sure enough, our football team was down by 16 points going into the fourth quarter. (I must confess, I had gone home already....) But you know what?

They rallied back and won.

Just like they are going to next week, too.

- Posted using BlogPress from my iPad

No comments:

Post a Comment