Thursday 20 August 2009

error checking

ok guys hello.

today i want to talk to you about error checking in your programs. I have been learning programming for a while now and i haven't really looked into error checking until today. I now realize the importance of error checking even when you are creating very simple programs.

for example today i tried to load up some images in an SDL application and it didn't work but I didn't know what was going wrong so i nievely asked in my forums what i was doing wrong not knowing or disregarding anything about error checking. I used to think it was for more advanced programmers but really it is for everyone! You should really get into the habit of checking for errors when writing your code.

In SDL for example in your main function writing something like this

    if( init() == false )
{
cout << SDL_GetError() << endl;
return 1;
}



could save you a hell of along time when it comes to looking for errors.
i didn't realize that something so easy to implement could save
me so much time. Its crazy. Having your errors output to the console is
an incredibly useful way of debuging your apps. SDL_GetError() is incredibly
useful because it tells you the problem in a really simple and easy to understand
way! seriously for me it said

paddle.png failed to load.

and i immediatly knew what the problem was. And now i can get around to fixing it.

Overall for any new game or just regular programmer for that matter, Error checking is
and absolute must!

1 comment:

  1. omg...I totally agree. As a newbie game programmer myself I didn't error check and man...it sucked D:

    ReplyDelete

money maker