ASSERT I : Assume makes a Burro out of U and Me

Assuming an object's condition or the condition of a part of an object is always risky. Especially hidden assumptions, things that you expect to be a certain way but find out that one time in a hundred actually contain complete nonsense.
The flip side on this is that your assertion is triggered you did or did not do earlier in the program. Don't get rid of the problem by removing the assert, fix the problem object before you get to the assert instead.

Too many assert()'s are not a problem. If you need to optimize them out, you can always wrap them in a macro that evaluates to a noop under release conditions.
The only issue is in the way they are implemented. DebugAssert(IsFileError()) is fine. DebugAssert(FileOpen() != NULL) is not.

No comments: