-
Notifications
You must be signed in to change notification settings - Fork 26.6k
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
Provide example of mid-variable acronym naming #2864
Conversation
Technically 23.9 says "Acronyms and initialisms should always be all uppercased, or all lowercased", however some counterexamples came up during a recent code review. Counterexample: a variable that captures a GHE (GitHub Enterprise) API (Application Programming Interface) URL (Universal Resource Locator) in the current rules can be (if all acronyms were to be used): * `GHEAPIURL` or * `gheapiurl` but it seems reasonable to allow: * `gheApiUrl` based on the spirit of "readability" (making the word boundaries clearer). So I'm just adding an example in hopes of not really needing to change the rule but still making sense.
@@ -3521,7 +3521,7 @@ Other Style Guides | |||
]; | |||
|
|||
// also good | |||
const httpRequests = [ | |||
const httpUrlRequests = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
first, let's keep httpRequests
; but second, Url
is literally never correct, ever, and should never appear in your code, so this would be a very bad example to provide.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Url
is correct in this case in Google's TypeScript, JavaScript, and C++ style guides
https://google.github.io/styleguide/tsguide.html#camel-case
https://google.github.io/styleguide/jsguide.html#naming-camel-case-defined
https://google.github.io/styleguide/cppguide.html#General_Naming_Rules
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately Google's style guides haven't ever been considered idiomatic by the wider ecosystem.
iow, |
I'm sorry I don't understand; what do "infinitely" and "aim higher" mean in this context? |
@ljharb you requested changes; what would you like me to change? |
"aim higher" means, let's do better than Java. I don't have a concrete change to suggest; if you can think of an example of mid-variable acronym naming that doesn't improperly case an initialism then I'd be happy to consider it. If not, then it may be best to close that. |
Technically 23.9 says "Acronyms and initialisms should always be all uppercased, or all lowercased", however some counterexamples came up during a recent code review.
Counterexample: a variable that captures a GHE (GitHub Enterprise) API (Application Programming Interface) URL (Uniform Resource Locator) in the current rules can be (if all acronyms were to be used):
GHEAPIURL
orgheapiurl
but it seems reasonable to allow:
gheApiUrl
based on the spirit of "readability" (making the word boundaries clearer).
So I'm just adding an example in hopes of not really needing to change the rule but still making sense.