Freigeben über


How ! to code

A little rant to prove I'm still alive. :-)

Here's a pattern I see every now and then that makes my brain explode. This is a simplification, but the two bools that are named exactly the same except the word "Dont" are real, as is the "partial assert" and not-completely-mutually-exclusive logic that follows. Can anybody explain why you would write code like this?

 bool fDoFoo = SomeLogic();
bool fDontDoFoo = SomeOtherLogic();

assert(!(fDooFoo && fDontDoFoo));

if (fDoFoo)
{
    // Do something
}

if (!fDontDoFoo && !fDoFoo)
{
    // Do some other thing
}