Question: I have a disagreement with one of my colleagues on whether or not functions should have inverse functions available.

I would like to know when/if inverse functions should be used.

For example, say we have a function `isTrue(boolean condition){return condition == true;}` then what I would do is also include a `isFalse(boolean condition){return !isTrue()';}` function, given that I know that `!isTrue()` is used in the code-base.

I argue that this makes the code more readable and less error-prone as you may forget to add the "!" (which has happened to me on occasion).
He argues that the function is superfluous as `!isTrue(condition);` is functionally equivalent to `isFalse(condition)` and therefore `isFalse()` should not be included in the API of the class.

Clearly he is right about them being functionally equivalent but I disagree that this means you should not include the `isFalse()` method.
I believe that I have read somewhere that my version decreases cognitive load but I can no longer find the source. Either way, my take is that "This condition is false" is easier to understand than "This condition is the inverse of true".

If you know of any sources on either my take or his and you can share them that would be appreciated.

Answer: 
Don’t not avoid negatives. Sure the cpu doesn’t mind them but humans suck at parsing them.

However, the idea that every function should automatically have some complementary function is silly over design if you can’t point to a real need.

Also, `!isTrue()` is not the [inverse function](https://en.wikipedia.org/wiki/Inverse_function) of `isTrue()`. It’s the [logical compliment](https://en.wikipedia.org/wiki/Negation). An inverse function swaps the input and output. A logical compliment negates the output.

Problem is the name `isFalse` is also a negative. It doesn’t add any meaning. You can avoid a `!` by picking the right name. Say, `isOccupied()` vs `!isVacant()`. But that only works when the name has a different meaning on it’s own. It doesn’t help if the name just gives you a negated meaning. It’s far better to use a name that has the correct meaning without needing a negative word attached to it.

So yes, sometimes a good name can avoid a nasty `!` but not all the time. It’s best to talk to your team and find out if this really helps them or not.
```
bool IsLate()
{
  return (Now > DueDate);
}

```

What's the complement method here? `IsEarly`? `IsNotLate`? What if `DueDate` is undefined or null (depending on the language)? Are you going with this implementation?

```
bool IsEarly()
{
  return !IsLate();
}

```

Well no, because you can be not late and not early. You can be right on time. What about this?

```
bool IsNotLate()
{
  return (Now <= DueDate);
}

```

Okay, you've got two methods to maintain now. Does that make sense in your problem space? Is it worth having two things to fix if you need to change the syntax or interpretation of `DueDate` someday?

Bottom line: *Write the code that does what you mean.* If what you mean is "that idea of lateness, do something when it's not happening," that's probably `!IsLate()`. If what you mean is "that idea of being on time or early, do something in that event," that's probably a separate `IsNotLate()` or `IsEarlyOrOnTime()` method. And if the straightforward way of expressing one of those ideas is directly in terms of the complement, okay, do that.

Let the code map to the problem space.