ruby / rails boolean method naming conventions
Posted
by
Dennis
on Stack Overflow
See other posts from Stack Overflow
or by Dennis
Published on 2011-02-09T23:00:10Z
Indexed on
2011/02/09
23:25 UTC
Read the original article
Hit count: 282
I have a short question on ruby / rails method naming conventions or good practice. Consider the following methods:
# some methods performing some sort of 'action'
def action; end
def action!; end
# some methods checking if performing 'action' is permitted
def action?; end
def can_action?; end
def action_allowed?; end
So I wonder, which of the three ampersand-methods would be the "best" way to ask for permissions. I would go with the first one somehow, but in some cases I think this might be confused with meaning has_performed_action?
.
So the second approach might make that clearer but is also a bit more verbose. The third one is actually just for completeness. I don't really like that one.
So are there any commonly agreed-on good practices for that?
© Stack Overflow or respective owner