I cry a little inside when I see a "negative boolean variable" like bAccessNotExclusive.  Makes my brain hurt.

Comments

  1. Reminds me of:

    case not IsNotTrue of
      true: begin
                 CheckBox1.Checked := True;
              end;
      false: begin
                 CheckBox1.Checked := False;
              end;
    else
      raise Exception.Create('...');
    end;

    ReplyDelete
  2. if not valid
    then ...

    No rules without exception?

    Edit: Ahem... you were thinking about the variable and implied state...

    if not IsInvalid
    then ...

    ReplyDelete
  3. if not (LarsCantSpell and LarsCantRead)
    then ...

    ReplyDelete
  4. We have one of those that made me chuckle over the years.  It reads like this... "if not no_pos_update".  You probably never saw that gem :-)

    ReplyDelete
  5. Ron Lawrence I can't even think like that -- seriously, it's like trying to drive in mud.  Just so hard to think about.  ;-)

    ReplyDelete
  6. As a hardware guy, I can tell you that one of the joys in moving fro TTL to CMOS (many years ago) was the availability of positive logic functions for all gates.

    ReplyDelete
  7. I've mentioned this beauty before

    if (some long complex condition)
    then // Remember Elsie Here
    else begin
      ... actual code

    ReplyDelete
  8. One of my favorites was in C++. The use of the ternary operator:
    a ? b : c;
    The actual entries for a, b, and c were each so long as to require horizontal scrolling of the screen.

    ReplyDelete
  9. A negative boolean variable as you name is could be interesting when that variable is added afterward to expand something existing. Frequently, in order to not break existing code which ignore the variable, the variable initial value must be false. This make the name with a negation mandatory.

    ReplyDelete
  10. In fairness, there was a time when all logic hardware involved negation, and many of us found it perfectly straightforward to design in that mode. However, I do agree that as a common practice, it were better to avoid it.

    ReplyDelete
  11. I was going to say what François Piette  said.

    ReplyDelete
  12. As a student I wanted to design an operating system with some fellow stutents, which would answer wildcard commands like "del *.pas" with prompts like:
    "you do not want to delete all .pas files do you? (Yes/No)"
    Needless to say that we intended to call it "SaDOS" :)

    ReplyDelete
  13. Lübbe Onken but would it use spoken English rules or logic rules? Usually when speaking 'don't you want fries?' The answer 'yes' is taken as 'yes I do want them' rather than as agreement.

    ReplyDelete
  14. That's why it would be called SaDOS. You have to find our yourself...

    ReplyDelete

Post a Comment