Archived

This topic is now archived and is closed to further replies.

Genjix

Error Checking versus Speed

Recommended Posts

What do you mean? Do you mean you don''t want to do any kind of error handling because of speed issues? Ummmmm, you should do error handling regardless. If you get an error how would you know what happened ir where it happened at? You release a game and the user gets an error, how would you know what to fix? I don''t get it...

-UltimaX-
|Designing A Screen Shot System|

"You wished for a white christmas... Now go shovel your wishes!"

Share this post


Link to post
Share on other sites
I use assertions to check for conditions that should never ever happen, then hope that they don''t crop up in release builds. For really significant things that would, say, make the user''s computer blow up, then I add error checking in addition to the assert.

I also wrote an exception class hierarchy for the app, but I suppose that doesn''t really answer your question.

Share this post


Link to post
Share on other sites
You should only use assert''s on things that should never happen. For example, asserting that a pointer isn''t null in a memory copying function is perfectly legitimate. However, asserting something that might fail depending on something at runtime, e.g. user input, should never be done.

Share this post


Link to post
Share on other sites
I highly doubt the overhead of error checking will be that much of an issue in your game. Having said that, my method is to use error checking for anything that can reasonably go wrong at run time (user presses an invalid key, can''t find a server, etc.) and thow an exception for everything else that I catch in my main function and terminate nicely with a little error message. As I''ve said, I doubt the speed is really that much of an issue, and I find this system to be easy to use and maintain, and yet functonal enough for gameplay and debugging.

tj963

Share this post


Link to post
Share on other sites
Correct me if I''m wrong but I get the feeling you''re just too lazy to do error checking and need a good excuse not to.
Which is understandable because error checking can be a pain, especially since it doesn''t contribute to the ''coolness'' of your game.
Well if your a hobby programmer:
If you can get yoourself to do it, do it, there are only advantages. Otherwise well just tell the users what hardware they need and hope all goes well in the game.

If you are professional:
Get to work and do those error checking routines.
-CProgrammer

Share this post


Link to post
Share on other sites
Error checking is good.

Premature optimization is usually just a waste of time. Especially if I read threads that say that using a for() loop with ++i is faster than i++ because it doesn''t allocate the counter on the stack. If that code is in your init functions, who cares.

Once you find a speed bottleneck with profiling in the finished project, you can consider removing some error checks that never fire, if it helps. Just leave the rest in, a messagebox that says error is better than a Dr.Watson or an exception that terminates your program.

Share this post


Link to post
Share on other sites