Benjamin doesn't have a lot of complaints about the project he works on. "There is," he writes, "no tale of daily woe." But even an otherwise healthy project isn't immune to WTFs.

BOOL CCache::CalculateBmpImageSize(SIZE BackgroundControl, SIZE& NewImageSize)
{
        BOOL    bRes = TRUE;

        try
        {
                NewImageSize = BackgroundControl;
        }
        catch(...)
        {
                bRes = FALSE;
        }

        return bRes;
}

In this C++ code, SIZE is a struct containing width and height. This function, then, is just handling an assignment: copying the size of BackgroundControl into NewImageSize, which is helpfully passed as a reference.

This is an operation that isn't going to throw an exception, and if for some reason this operation fails, mere exception handling isn't going to recover the program. And then there's the entire "take structured exception handling and turn it back into return codes," which is also likely not the best choice.

"Who knows," Benjamin writes, "maybe tomorrow this assingment will need to be replaced by a complex mathematical equation." That, or I suspect that the developer responsible for this got burned by overloaded operators in the past, and has become overly cautious about them.

Sometimes a cigar is just a cigar, but sometimes an = is actually a complex operation written by a developer who wanted to be "clever".

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!