-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
? semantic hinting #33
Comments
/cc @garyposter @pedro - I know we discussed this a bit recently, so I'd certainly welcome your thoughts. Thanks! |
Nice, this looks great to me! I'm not sure about how universal the I prefer it in particular for writeable attributes, where a change to a noun (eg: |
Hmm. It might point to a broader issue with naming. ie, maybe it should be |
Hmm not sure the new terms add much. For instance, I don't see any ambiguity in "maintenance" to justify "maintenance mode". "Beta features" is interesting because it does correlate with account/app features, but in practice this flag also gives users access to private beta addons, so this might call for the more generic name. |
|
How about |
@frankieroberto - yeah, definitely another good case to include. |
I do like the idea of using suffixes as clear indicators of data types. OTOH it doesn't feel natural enough yet for bools, per Pedro's examples. I'm not sure I entirely agree with @pedro that "maintenance" has no ambiguity. If I know it is a bool, it's fairly clear, but otherwise it could be a date with one semantic, or a comment field with another. A |
I'm not particularly keen on It's also worth considering that most usage of boolean attributes will probably be checking whether
...without breaking any API clients. |
I'm a fan of type annotation for booleans via prefixes/suffixes. I've too often had to ask "is |
@jroes if all dates end in |
@garyposter is_ does have some precedent, but I guess I don't feel awesome about it in this context. @jroes I agree that something seems likely to be valuable, just still not sure what. @frankieroberto very true. That said, I think in terms of disambiguation, presence of something beats absence of the other thing. That said, it seems hard to nail down a discrete naming convention that works for all booleans (so far anyway). Even in your example I wish for greater consistency I guess, ie Maybe it is a matter of saying that booleans should just be past-tense verbs (or at least end in one). I would expect other attributes to be nouns (or end in at/on like times/dates), so this in and of itself colud potentially disambiguate. Examples from above would be |
Don't understand any it |
@JOEFOSTER9 any questions I could help with? |
What exactly is this |
How do u use this |
The idea here is to name properties following a particular pattern in order to hopefully make it clearer to an end user what the type and intention of the property might be. |
Examples?
|
The easiest examples are probably things like created and update timestamps. You could for instance have:
or
It's a small point really, but it seemed like it might be a nice guiding principle when naming some things. The trickier extension, mentioned above, is if there was a reasonable way to have a similar suffix to indicate something is a boolean. The proposed version was |
Stop
|
To better communicate the purpose/intention of attributes it can be useful to use semantic hints (similar in a sense to type hints). They generally appear as suffixes to attribute names, a couple examples we use consistently:
#{past_tense_verb}_at
for timestamps#{past_tense_verb}_on
for dates (time can be ignored and/or should be midnight)Another case we have discussed, but that I'm not quite as convinced about yet. I'm not sure how universal it is, but I think it does make it more human-readable and a bit easier to reason about:
#{noun}_enabled
for boolean values. Historically we have a mix of these and just#{noun}
for boolean attributes, it seems as though choosing one or the other at least would be better.The text was updated successfully, but these errors were encountered: