Pre-conditions and unsafe constuctions
mateusz at loskot.net
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?
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
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
More information about the Fdo-internals