On Mon, Jan 06, 2003 at 04:19:35PM -0800, email@example.com wrote:
> Asserts are generally a bad thing IMO. If something should be checked in
> debug code, it should also be checked in production code.
Asserts are not for argument checking.
Argument checking is for verifying inputs to your module/function/method.
Asserts are used for internal consistency checking.
Module interface (public methods)
Module implementation (private methods)
You would put argument checks in the interface methods and add asserts in the
So if you have a class Array with a method getAt(i) you would verify
i < arraySize
but you would assert that
arraySize <= allocatedArraySize.
> As for pointers
> being passed without checking for NULL, those checks are usually a waste
> of cycles. If the value is incorrect, then you are most likely to catch
> those problems in your debugging. You are more likely to catch those
> problems if your program segfaults than if you rely on a log message that
> you may miss.
And what if it does not segfault but randomly scribbles some buffer
before commiting to database? A wild pointer access will segfault only
if it points to memory the OS knows you should not have. If it points
to allocated memory, you get random coruption.
"NT is to UNIX what a doughnut is to a particle accelerator."
Received on Tue Jan 7 01:27:40 2003
- application/pgp-signature attachment: stored