I have a property that indicates whether the instance could be modified. Should it be named MayModify or CanModify?
CanModify is better, because can represents ability. But May is more like someone is not against, not that definite.
IsModifiable
CanModify
AllowChanges
MayModify sounds too conditional, sort of grey as opposed to boolean black and white.
I would usually use a verb followed by a noun. Ie:
Allow, then Changes.
CanModify is two verbs/actions which I think is confusing.
Neither.
IMO you should use Is
prefix. It is somewhat recommended.
So I would go for IsModifiable
See this thread: Naming Conventions: What to name a boolean variable.
An instance that cannot be modified is read-only, no? So IsReadOnly
?
CanModify
is a perfectly good name, but it would be wrong in this scenario. When naming properties, you always have to think of typical usage.
MyClass widget;
if (widget.CanModify) { ... }
Clearly it is widget that is modifying something else. But you wanted to express whether the consumer can modify widget. So this name would be very very bad.
My preference in this case would be:
if (widget.IsWritable) { ... }
or
if (widget.IsReconfigurable) { ... }
depending on what exactly "modifying" the widget means.
But even
if (widget.CanBeModified) { ... }
would be much better than either CanModify
or MayModify
, both of which sound like they give widget
permission to modify something else.