views:

151

answers:

4

I'm trying to come up with some clear and concise names for a Permission class that lets you check if a permission is, was, or will be, allowed/denied. I'm at a loss for what to call the future tense.

class Permission:
  def can_read()
  def could_read()
  def will_read()?
  def will_be_readable()?

I'm most partial to will_read(), but it sounds funny. will_be_readable() is clear, but its kinda long, and will_be_read() sounds misleading.

+1  A: 

Yeah, English really has a problem here, with no future tense of "can"! What about switching to (say) readable_now, readable_past, readable_future? If past and future have specific meanings in your case better naming could be worked out here, I'm sure.

Alex Martelli
+3  A: 

Since you are looking for a permission class, the code will be formulated as a question:

if (the_user.can_read()) ...
if (the_user.can_read_past()) ...
if (the_user.can_read_future()) ...

Apart from that I would try to maintain equal prefixes for the semantically equal function, and I would leave off the suffix for the default/most likely case. I have no real problem sacrificing grammatical correctness for a logical naming structure, even though I like to gear code towards natural language. So something like that is what I would be going for.

The will_read() sounds more like an event that is triggered before the action.

EDIT: I am aware that "can_read_past" may be percieved as "can read old stuff". Maybe Scott Evernden's suggestion is better?

Tomalak
fwiw: .can_read_past() implies that the user can currently read, but only past events. Perhaps: the_user.had_read() or something along those lines.
Metro Smurf
To the unaided eye, yes. I know it's not ideal. I tried to remain consistent assuming that can_read() is the default, expected case, and the other two are variations of it. I thought of it as "can_read()" with a "past" modifier, not as "can read old stuff". But then again, I'm not a native speaker, so I can't really say how strong the instinctive preference for the latter would be.
Tomalak
A: 

Since it is related to if a permission is allowed/denied, maybe there is a more descriptive word than read?

can_authorize
authorized
scheduled_to_authorize

OG
+1  A: 

was, is, and will_be is clearest to me.. or maybe readable_before, readable_now, readable_later

Scott Evernden