Today's submission is less a WTF and more a, "Yeah, that'd annoy me too."
Stevie works in a code-base that's largely C, which means function return values are usually used to communicate to status codes. The standard:
BOOL success = someFunc();
if (!success) {// handle the error
If someFunc returns TRUE, we succeeded, otherwise we failed.
There's nothing wrong with that convention. But there is something wrong with one of the long-time developers on the project, because they have their own idiom for doing this. And they've been around long enough that their approach is the convention other developers follow. It's not wrong, per se, just confusing:
BOOL error = someFunc();
if (error == FALSE)
{
//handle the error
errorCode = GetLastError();
//…
}
Yes, pretty much anywhere an error can happen, they check if error == FALSE, and if that's true, they have an error.
I'd say, "at least they're consistent", but they're not. It's the convention, sure, but nobody wrote this down as the convention. New developers come in all the time, and they start out writing code in a more "normal" pattern. But the existing code has its pattern, and there is a lot of it. It has a mass and an inertia that is stronger than any developer. They don't change the code, the code changes them.