Advertisement

Dumbest coding mistakes ever

Started by February 07, 2012 01:19 AM
53 comments, last by Bacterius 12 years, 6 months ago

//Boolean logic Fail
if (DateTime.Now.DayOfWeek != DayOfWeek.Saturday || DateTime.Now.DayOfWeek != DayOfWeek.Sunday)
{
weekday = true
}
else
{
weekday = false;
}



I did something very similar with SQL:


select dept, job
from organizations
where (dept = 'Marketing' and job <> 'Sam Wise')
or (dept = 'Marketing' and job <> 'The Precious')





Note: Shout out to the GD.Net crew who got the keywords to automagically highlight properly without having to declare what language you're using. Impressive!

Beginner in Game Development?  Read here. And read here.

 


Note: Shout out to the GD.Net crew who got the keywords to automagically highlight properly without having to declare what language you're using. Impressive!


Side note: they use this guy.

[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]
Advertisement

//Boolean logic Fail
if (DateTime.Now.DayOfWeek != DayOfWeek.Saturday || DateTime.Now.DayOfWeek != DayOfWeek.Sunday)
{
weekday = true
}
else
{
weekday = false;
}


Nonononono, you don't get it, that isn't boolean logic fail, that's company manager boolean logic (especially true in crunch mode!).
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.
Just today I wrote:
auto TemporaryHeart = MoveHeart(State[8], State[10]);
MoveHeart(TemporaryHeart, State[12]);
MoveHeart(TemporaryHeart, State[3]);
MoveHeart(TemporaryHeart, State[8]);
TemporaryHeart = MoveHeart(State[9], State[11]);
MoveHeart(TemporaryHeart, State[13]);
MoveHeart(TemporaryHeart, State[2]);
MoveHeart(TemporaryHeart, State[9]);

Instead of:
auto TemporaryHeart = MoveHeart(State[8], State[10]);
TemporaryHeart = MoveHeart(TemporaryHeart, State[12]);
TemporaryHeart = MoveHeart(TemporaryHeart, State[3]);
TemporaryHeart = MoveHeart(TemporaryHeart, State[8]);
TemporaryHeart = MoveHeart(State[9], State[11]);
TemporaryHeart = MoveHeart(TemporaryHeart, State[13]);
TemporaryHeart = MoveHeart(TemporaryHeart, State[2]);
TemporaryHeart = MoveHeart(TemporaryHeart, State[9]);
I had one mistake that was just so dumb that I overlooked it. The functions worked independently but when i tried using them together...


void function1(Blah whatever)
{

//Tons of code
for(int i=0; i;whatever.count; i ++)
{
//tons of code
function2(whatever);
//tons of code
}
//more code
}



void function2(Blah& whatever)
{
//lots of code that does stuff
Blah whatever2 = new Blah();
whatever.count ++;
//more codes
}



I seem to always mess up iterators in functions.
Made this mistake a few times, very hard to spot in some situations.
[source]for(int i=0; i < i_max; i++)
{
for(int j=0; j < j_max; i++)
array[j];
}[/source]
Advertisement
Sounds like for the most part most people here would benefit tremendously from better tools. I haven't been hung up on anything like this for a couple years now. Check out the video showing how most of these types of problems can be avoided using good tools. It's not going to help most of the logical problems, but it does a fantastic job of helping you avoid silly errors like where a semi-colon is placed.

http://screencast.com/t/U9s4FW1HM9su
Today I forgot to compile something after making changes that should have totally changed the behavior of something and it took me a few minutes to realize why the behavior wasn't changing at all.

/monday

Today I forgot to compile something after making changes that should have totally changed the behavior of something and it took me a few minutes to realize why the behavior wasn't changing at all.

/monday

This happens to me sometimes when I'm working with our branch and trunk at around the same time. It can drive you crazy!

Today I forgot to compile something after making changes that should have totally changed the behavior of something and it took me a few minutes to realize why the behavior wasn't changing at all.

/monday

Reminds me of when I made a quick fork of a game to add time attack for a special event. No matter how hard I tried my attempts at resetting the timer would not work no matter what, it was like it was completely ignoring the code I was writing. Turns out I was editing the original file, not the one from the fork *facepalm*
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.

This topic is closed to new replies.

Advertisement