I’m pretty sure most of us have been in a situation where we have been trying to fix a bug for hours and finally seeing that there had just been some tiny typo or maybe even a commented line of code. I’ve been through a lot of those experiences before, especially when I was still learning to code, and most of the time, I just breathe out a huge sigh of relied or just plainly laugh at myself.
Reminiscing about those ‘good old days’ could be fun too. Here’s some of those ‘what the hell/oh come on/I knew it was just a simple mistake!’ scenarios that I have experienced or just know of:
- A missing/extra space, comma, or whatever character in your code. When this happens, it usually takes a while before you realize it because most of the time, you assume that what you typed was correct. Especially with missing spaces, it really is hard to tell. I have had one experience before in coding in Flash, where my fellow coder had 3 extra spaces after the instance name of a clip. No wonder we couldn’t access the variable!
- Unpopulated database. I think Bit had experienced this too, when he was launching the AnimoAteneo.com site. I have also experienced this recently, where I KNEW my code was correct, but the reason why it wasn’t printing out anything was because it didn’t select anything(I was trying to select events during a week, which was stored in database…and the problem was there were no events that week).
- The semi-colon of emptiness. There are rare times in the life of a programmer(especially ones that still use the ancient arts of Java and other compiled languages) when s/he encounters the…wait for it…semi-colon of emptiness(SFX: thunder crash). This is one of the most frustrating things that can happen to you: accidentally put a semi-colon after an if statement. Although it has been used deliberately for empty if statements, some still accidentally put a semi-colon after the if statement, which invariably makes it useless. And for that, we have to thank those other languages that don’t require a semi-colon.
- HTML entities. These guys are a nightmare, especially with a database involved. tick-marks or whatever you call it are often confused with apostrophes, tabs(nbsps) with spaces, long dashes with short dashes(sounds weird but it does happen), etc. It is a real pain especially when the program or database doesn’t complain about it and you just find out about it after they have wreaked havoc in whatever you were working on.
- Uncommented/commented lines of code. This happens especially when you are using the “try and try ’til it works” approach in coding. This also happens when you are trying to debug your code and you forget to uncomment/comment some lines that subtly affect whatever your code was doing – like, say – assigning a static/hard-coded value to a variable.
These are just some of the mistakes that we can encounter while coding and minimizing the chances of these happening can help in coding a lot faster and having more time dealing with bugs that matter.