I continue to find it rather amusing that even (so-called) experienced developers will use fundamentally different concepts interchangeably, even after doing this for so long.

For example, I have seen documentation by developers that mention nul values in a database table, or worse yet, NULL-terminated strings, and NUL pointers.

Now, some that simply miss the point will be saying something like: “In C++, NULL is zero, and the NUL ASCII code has a value of zero, so they are the same thing!”

  The values of the two identifiers may be the same, but not their meanings, and thus, it is inappropriate to use them interchangeably.  Here is an example.  In the VC++ environment, the following identifiers are present:

    NULL = 0
    TRUE = 1
    IDOK = 1

But just because some of them have the same value does not mean that it is correct to do something like this:

    int iRet = COLOR_SCROLLBAR                                 // Initialize iRet To What Value?

    iRet = ::MessageBox( 
        "Please press [OK] to continue or [Cancel] to cancel the delete operation.", 
        "Please Confirm Delete", COLOR_BACKGROUND | NULL );    // What Kind Of MessageBox?
    if( iRet == TRUE )                                         // What Button Are We Looking For?
        // Do Delete Operation

According to the if the identifiers have the same value they mean the same thing argument, the code above is perfectly fine.  Of course, as demonstrated above, that is a bullshit argument.  After all, what would you think if you saw code written like that? It would likely end up on The Daily WTF.

Leave a Reply

You must be logged in to post a comment.