Monday, July 12, 2010

Programming with defines and Toast

Everyone should program and use defines. I know i don't usually make statements that are so cut and dried. However in the case of using defines over actual values in the game i am very Very set. I am actually writing this because of what happened recently to one of my projects. We have a set of values (game ids) and for some reason the values were never setup as defines. Though in lua defines are not pre-processor efficient, which is a real pity. However we still strive to use them because of readability and consistency.

So there we have people typing in the game id all over the place. I just never really noticed it and so never addressed it.I would have either fixed all the files up myself or got one of the other programmers to fix up all the games. I love consistency and this kind of thing can only lead to no good. Usually noone notices this kind of thing too often, it never quite tends to bite ya in the butt, in my case and long history of coding and doing games though i have seen this kind of thing turn bad several times.

This one caught us out in The Midway, and has cost us some money, we believe that it has cost us possibly thousands of dollars. We cannot of course estimate how much, but we know it wouldn't be a small number. It took me a few hours to trace the issue and eventually the bug we had was simply an inconsistant game id typed in. I suspect that this particular game id was changed at some point from 5 to 7, but then the code was broken. However if a define had been used a complete reorganization of the game ids cold happen and there wold be no side effect, although they can still be misused and break code (by using greater or less then compares etc). I have of course fixed this bug by simply using the correct value of 7. It did get me to call a programmer meeting to discuss this issue and remind all of us programmers of the importance of defines. It was a good meeting, even if it is one that i wished i had not had to call.

Toast is great, one of those foods that is just great... Burn some bread to a certain amount and for some reason it takes on some different qualities than just bread. For the last few days i have had some for breakfast with butter and jam on it. Yum yum it is tastey. I do not know why though, but the toast just seems to taste better in Britain than it does in California. I do not understand this, but would love to, so i can fix me Californian toast.

It is now raining and so i am going to walk to the shops and enjoy getting wet along the way. Then it is off to visit more family. YAY!

Have a great day everyone

No comments:

Post a Comment