Naming a predicate: "precondition" or "precondition_is_met"?
- by RexE
In my web app framework, each page can have a precondition that needs to be satisfied before it can be displayed to the user. For example, if user 1 and user 2 are playing a back-and-forth role-playing game, user 2 needs to wait for user 1 to finish his turn before he can take his turn. Otherwise, the user is displayed a waiting page.
This is implemented with a predicate:
def precondition(self):
return user_1.completed_turn
The simplest name for this API is precondition, but this leads to code like if precondition(): ..., which is not really obvious. Seems to me like it is more accurate to call it precondition_is_met(), but not sure about that either.
Is there a best practice for naming methods like this?