This could rather be a post on I Get Your Fail, a very entertaining site by the way. I started to note down stupid mistakes which took hours* to resolve, so here are the first two:
Case 1: happened @Level Master 2000, Qt/C++:
if( something = 0 ) { //... } |
Eventhough I debugged over this several times, I just kept wondering why something suddenly is null, and of course, being new to Qt, I claimed it to be causing that…what else should I say: I’m sorry Qt, for being so mean!
A colleague of mine told me, that in such cases, some people prefer to write 0 == something, cause if you forget the second “=”, you get an error. I’ve tried to adapt to this way of coding, but it somehow looks really weird, and I can’t say for sure if I can continue with this style…(more errors to come! =) )
Second case: I recently did some C# programming again, loving to use properties. But if so, it can be evil to use them before they are initialized / assigned to (well, actually this applies to all members, not only properties):
//In a constructor... someotherthing = something * NumTiles NumTiles = numTiles |
So in that case, using NumTiles before being initialized, resulted in NumTiles returning zero, which led to someotherthing being total nonsense…and resulting in me going crazy!
I’m curious about the next time(s) I’m gonna stumble over myself again – it’s only a matter of time, I’m sure about that.
*: Ok, not maybe real hours, but at least it feels like so…