6

Do you prefer to negate a positive function or write a negative one?

Example
!IsValid() vs IsInvalid()

Comments
  • 6
    That would depend on the original field i use. If the field first expected to be told something is invalid then ill use IsInvalid()

    Though often i use negate positive since saying 'not InValid' feels clunky
  • 3
    The former
  • 2
    This might be a question for the philosophers, but I also prefer leaving the 'not' to the logical operator by default to avoid double negatives when reading.
  • 1
    IsValid, but we can do better! Validate on rulesets to avoid many if blocks for validation checking is far clearer IMHO. 😉
  • 3
    !isNotInvalid()
  • 0
    @crisz you're a monster.
Add Comment