Your Worst "Gotchas" ever in programming

Started by
68 comments, last by Icebone1000 11 years, 2 months ago

semi-colon at the end of an if statement.

Why are you ignoring the state of the flag?? Why do you keep going into that code block? WHY??

Maybe the code isn't synced with the debugger! I'll rebuild. Nope, same problem. Stupid compiler/debugger/toolchain!

This. So annoying.

Advertisement

Watch this one for a laugh:

https://www.destroyallsoftware.com/talks/wat

Seriously, what's with programming languages? =/

Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.

I wrote a function to apply blurring to an image stored in a 2D array passed in (VS2010, C++). The function had a local 640x480 2D array on the stack. Calling the function caused really strange things to happen and had me baffled while trying to change random things to make it better. In the end, it turned out it was a stack overflow, with the additional array sending it over the top of the default 2MB size. That was a weird one. It would be nice if something indicated the problem in debug mode.

I once typed this in some multi-threaded server code and spent an hour trying to figure out why things were not working.


while(server->active);{
   // Not important.
}

.. in case you can't see it.. look at the extra ';' and what it creates in the generated logic.

in my first text adventure i made a casino function that was supposed to be a place payers could spend their money with an opportunity to make more and use that for upgrades stat boosts, etc. however i will always remember that function because that was the first time i encountered a rogue curly brace. I kept running the function and it kept outputting the same exact results, which made the entire structure pointless especially since it was supposed to be a gambling area. i studied that function for about a week before i decided to just read the entire thing line by line and discovered that by me missing one curly brace the entire function , barring one case, was ignored by the compiler....... to this day i consider the rogue curly brace my greatest enemy ......

I will probably get the your a dummy look.

Worked on a game with a group of people using Flixel. Was good but we needed a few things that FlashPunk offered instead. Ported all the code over to FlashPunk. Decided to mock up some UI in good ol Flash oldschool style. Linked everything together and.. voila. White Screen.

Tried again day after day after day after day. We were all stumped on why the project file wasn't working.

That day I learned I was somehow able to link a .as3 file to a .as2 FLA. I still do this day have no idea how I was able to do it. However when the problem was fixed it still was a white screen.

Stepping through everything we relized we were all a bunch of dummys. Line 3 started the Flixel engine. We never started FlashPunk. Everytime we started it we did isolated tests with Flashpunk with some Copy Pasta.. man I felt dumb.

I usually just give my 2 cents, but since most of the people I meet are stubborn I give a 1$ so my advice isn't lost via exchange rate.

I once typed this in some multi-threaded server code and spent an hour trying to figure out why things were not working.


while(server->active);{
   // Not important.
}

.. in case you can't see it.. look at the extra ';' and what it creates in the generated logic.

This is a big part of the reason I never open my brackets on the same line as my conditionals.

Semicolons are just as easy to miss even if you put the brackets in a different line.

Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.

memset (&mywonderfulstruct, 0, sizeof (&mywonderfulstruct));

The evils of copy-and-paste, and it's so bloody subtle; thankfully I noticed it right away but damn - it was close.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

I once made a switch() with a few cases in it, then I decided I'd prefer it as a series of if's and else's (I needed more control)...but I left the 'break' statement in one of the if's...then copied and pasted that if a few times, with the 'break;' still there...

In short: bye 30 minutes, I'm sorry I didn't make much out of you

[twitter]Casey_Hardman[/twitter]

This topic is closed to new replies.

Advertisement