Thursday, September 21, 2006

Comments are cool, Comments are fun...

Comments make their food from the rays of the sun.

Coding is more fun with people who are willing to leave comments in the code like this one:
// to all evildoers, this SQL statement
// must accurately reflect whether or
// not there is a DB connection.
// if it is ever trying to access a table
// that doesn't exist, it will always
// return false. do not change unless
// you know what you are doing.


This was in a function where I was getting an "access in invalid memory" error from Borland's CodeGuard.

This was due to the fact that this base dll is used in applications that don't create the base database object because they don't operate on the database at all.

A simple
if ( bool( Object ) )
{
// logic here to determine if the database is connected
}
else
{
// logic here to handle the lack of database functionality
}

would have helped.

Moral of the story?
Never assume you have a valid instance of a global variable... especially in a statically linked dll that relies on the global variable being created in the main application.

0 Comments:

Post a Comment

<< Home