Saturday, May 24, 2008

Programming is pain (sometimes)

Last night I went to bed completely frustrated. I had spent probably 6 hours staring and poking at a piece of code and thinking what on earth could be wrong with it. It seemed functionally identical to the code I had been using as a guide, yet it didn't work. It didn't do anything - generate error messages, any messages at all - it just got silently ignored by the framework. Why, why, why, is all I could think about before going to bed.

But what I've learned and seen reinforced over and over again is - if you get completely stuck, step away from the problem for a while. Take a nap or a shower or watch a movie or do something to take your conscious mind away from it. Sure enough, when I woke up and went back at it, less than 1 hour in I spotted the discrepancy. I had a function included in a class definition, while my example code had the function outside the class. So I took it outside and hey presto it worked perfectly.

It still sucked though to have to go through all that frustration.

No comments:

Post a Comment