Pre-conditions and unsafe constuctions

Mateusz Loskot mateusz at
Wed Dec 6 18:24:44 EST 2006


Where can I find what is pre-condition about input parameter,
if it's not tested with exception/assertion?

For example:

void FdoRdbmsOvClassDefinition::SetTable(FdoRdbmsOvTable *table)
    mTable = FDO_SAFE_ADDREF(table);

Are we sure table won't be null pointer?
Let's assume it is null, the FDO_SAFE_ADDREF macro initializes mTable
with NULL, next operator-> throws an exception.
Is this considered as enough level of parameters validation here?
According to my taste, there is no possibility to detect what's the real
domain error, so the exception here is unusable.

Why not to throw domain error related to SetTable() operation?

I found quite much similar places and I'm wondering may be these
pre-conditions about input parameters are documented somewhere.
So, it would be clear where NULL is acceptable and where it is not
acceptable and *not* possible to be passed because it's promised by
other entities.

For my own testing purpose, I'm guarding all these "unsafe" place with
assertions, so I can track potential problems easier and faster.
As we've discussed already, these assertions will be removed
before release.

Mateusz Loskot

More information about the Fdo-internals mailing list