・ Usable patterns-> is + adjective, has + past participle, triad present verb + noun, auxiliary verb + verb -Anti-pattern-> Yes and No are not clear naming ・ When you want to describe the subject, exceptionally the subject + triad verb
Ask if you are in an adjective state ex) isEnabled
Ask if you are in a verb state ex) hasSent
Ask if there is a noun in the state of the verb Can be omitted if the noun is clear ex) hasError
Ask if it is possible and if it should be ex) canRemoveItems ex) shouldContinue
Added on February 21, 2019 Is there an auxiliary verb? None? I received the comment. I often see booleans that use auxiliary verbs, and I think they also apply to the general rule of starting with a verb. Therefore, I added it.
ex) checkValid
ex) isEnable, existError → Correctly isEnabled, existsError
For example, when trying to express whether a user exists with boolean, I found the following as an expression in GitLab.
public boolean userExists
public boolean isUserExists
public boolean existsUser
I like the first pattern the most. When I try to express it in English If user exists, ... because. Since there is a rule to start with a verb in principle, there may be a second or third pattern, but it seems strange as an English grammar, so I do not use it much.
There was also a discussion about naming conventions when having a subject on stackOverflow. https://stackoverflow.com/questions/1566745/boolean-method-naming-readability
Even if you look at this, it seems that userExists is the most.
Also, if you have an object called user, you should write user.exists ().