Why small mistakes are disastrous?

I made a stupid mistake. very stupid one!

if(!IsOK())
{
    OkDoIt();
}
else
{
    NoWait();
}

Do you see the problem?
Yes, only one character ruined the whole process.

It should be like this:

if(IsOK()) // if(!IsOK())
{
    OkDoIt();
}
else
{
    NoWait();
}

If the function containing this problem is rarely called, it’s a time bomb inside a briefcase. Even after you recognize something is wrong, it’s very hard to find this kind of mistakes because it’s such a small one like off-by-one error. almost invisible. That’s why small mistakes can be much more disastrous than big ones which are obviously more visible.

Since code like the above is usually written very quickly and unconsciously without thinking, if you don’t have right habits, you will make a mistake. It brings me the idea I loved but, apparently, forgot.

Good programmers have good programming habits.

I will never use ! in if statement. ever.

One more thing to remember.

Test every changes you made. Every single line.

Of course, I tested my changes before I checked in it. However, there were many changes and I just quickly checked a normal flow without checking all the changes I made. I was focusing on bigger and more complicated changes. I should have kept my changes small and checked in them more frequently.

Anyway, it’s absolutely my fault and I will never forget it.

I really don’t think anything I do is a mistake. It could be if I didn’t learn from it. – Fiona Apple

Advertisements

About 리안 / Young

글쓰는 게임 프로그래머. 남편 그리고 아빠. Game Programmer Writing. A husband and a father.
This entry was posted in Uncategorized. Bookmark the permalink.

One Response to Why small mistakes are disastrous?

  1. Young says:

    One of our sr. programmer made the exact same mistake last week. maybe it's time to add it to our coding standard.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s