How much integrity checking???

Started by
3 comments, last by Noods 20 years, 9 months ago
In coding my current program, I find that I am writing integrity checks everywhere possible. How much integrity checking is optimal? Is there a time when I shouldnt worry about integrity checking?
Advertisement
What kind of integrity checking?

As in checking if D3D initialised properly, checking that Blits worked etc? If you''re constantly doing checking of your own objects then maybe you''re object structure is a bit screwey?

Why you shouldn''t use iostream.h - ever! | A Good free online C++ book
Any reasonably large program will need and have some form of integrity checking (or exception handling). But if you find yourself checking all over the place then what that means is you don''t have a clear picture of how the program is supposed to work and you are compensating by doing checks ALL the time just to cover your butt... this actually isn''t all that bad during debug but generally it needs to be avoided.

What language are your coding in? If it provides a mechanism of dealing with and detecting errors, then my first suggestion is to use that. Even still you need to have a clear idea of what points in your code the checks need to be at.

super genius
I basically make a check that everything is ok at each point where the program could unexpectedly crash. i.e.

//create tab control

//generate an error and bail if tab control couldnt be created

//create DirectPlay

//generate an error and bail if Directplay couldnt be initialized

//create childwindow

//generate an error and bail if couldnt create the child window


I do this because I have had problems when running a program on a different machine then my own, and it would close unexpectedly without any sign of what the problem is. With these checks, I (or the user) am able to tell what the problem is (old version of directx etc) I just find that Im doing the checks a lot
Maybe you should look into using c++ exceptions. It makes error handling a lot more simple.

Why you shouldn''t use iostream.h - ever! | A Good free online C++ book

This topic is closed to new replies.

Advertisement