Search code examples
coding-stylenaming-conventions

Using did as boolean flag name


I named one of my boolean parameters didInfoChange.

Many people on my team tell me to change it to isInfoChanged, which I don't agree. It maybe because my team members aren't native English speaker (neither am I), but I feel that ifInfoChanged is just isn't right.

didInfoChange -> Did information change? -> True/False

is pretty understand in my oppinion

isInfoChanged -> is info changed?

just does not sound right. It's probably not a big deal to fight about this, but I did some search and people do not really use did for flag name. I'm ok with hasInfoChanged but has and did is basically the same thing.

I'm wondering why is did not ok?


Solution

  • There are two questions here:

    1) Which is better, didInfoChange or isInfoChanged?

    The English word "change" can be transitive or intransitive, but in this context it is clear that "the info is changed" and "the info did change" mean exactly the same thing. (There is a subtle difference in connotation, but it is of no importance here.) The two names have the same length. There seems to be no difference except style convention.

    2) If your way is better than theirs, what should you do?

    Consider the consequences of your actions.

    If you have the power to persuade the rest of the team to use your variable name, at no cost, then do so. If doing so would cause stress (e.g. by commanding your subordinates to do something they consider a bad idea), then the improvement in style probably isn't the cost to the group dynamic.

    If you cannot persuade them, but you can prolong the argument and prevent the team from doing constructive work, then... don't. Use their variable name.

    If you cannot prolong the argument, but you can make yourself unpopular by being argumentative, then... don't. Use their variable name.