-
Notifications
You must be signed in to change notification settings - Fork 345
Change camel case acronym rules #37
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
Conversation
In the JS guide, we’ve explicitly chosen to always capitalize or lowercase acronyms and initialisms, because we have no need to cleave to a camelCasing algorithm designed to make life easier for machines, and we prefer names to make more sense for humans. |
@ljharb Thanks for the feedback. I actually think that this new way of doing things is easier for humans as well. There are lots of ambiguities regarding acronyms and camel case that will be gone if we use TrueCamelCase. Along with the lack of spaces cases mentioned in the original description, here are some examples: Examples:
I think the new rule is superior in terms of readability, and not to mention the fact that code is easier to read when we don't have to write extra rules to make it easier for the machine to understand it as well. On Apple's own Swift rules it says that everything is |
I'd also like to include this screenshot from the official Swift API Design Guidelines. One of the guiding tenets of the style guide is:
This change would contradict the Swift API Design Guidelines. |
@bachand While I think we should follow the Swift API Design Guidelines as much as possible, when many signs of human readability & machine processing point in a new direction, I don't think we should let those guidelines hold us back. As I mentioned above, if we adopt this new rule we won't have any ambiguous exceptions to our camel case variables and the rule will be one sentence. |
How easy would it be to exempt code defined by an external API from our style guide? Could we say "use all caps acronyms except when required by an external API"? |
In my mind I don’t view Apple’s rule as inconsistent. All things being equal I would prefer a rule that didn’t have exceptions. However I also think that the exceptions in this case seem well-reasoned and easy to follow 🤷♂️ |
Seems to me like the primary conflict here has to do with the naming conventions of different languages, and it feels wrong to me to allow the naming conventions of one language to influence those of another. I don't think we should be considering languages that use IMO, the conventions outlined in the Swift API Design Guidelines result in the most elegant and readable Swift. |
@jqsilver do you think we would want to add a guideline like that at the top level of the guide? I can see external frameworks / API requiring us to deviate from other style rules as well. |
Okay, I’ve been convinced that we shouldn’t let other languages or api
conventions define our style (besides swift and cocoa). I think if we could
just organize our code so that we easily exempt certain files then I’d be
satisfied.
…On Thu, Jan 10, 2019 at 2:59 PM Michael Bachand ***@***.***> wrote:
@jqsilver <https://github.com/jqsilver> do you think we would want to add
a guideline like that at the top level of the guide? I can see external
frameworks / API requiring us to deviate from other style rules as well.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#37 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ACP_SrJUkWI8njwD1u5prLHWdpBpIrNRks5vB8W4gaJpZM4Z6Ja1>
.
|
I voted yes but only because of Codable. Even though there are some edge cases as pointed out above where camel casing is more readable, Imo camel casing acronyms is generally less readable because I'm used to seeing acronyms uppercased. |
I'm pretty optimistic about being able to implement simple, performant If we're unable to do this successfully or we deem the cost of this to be too high (performance, maintenance, safety, etc.), then I'd be happy with organizing our code to allow for exceptions for |
I would really, really like to stick with Apple's approach here, and keep acronyms uppercase. If most / all of Apple's Apis are following one convention, I don't like us deviating from that (for consistency reasons). Also, capitalizing acronyms conveys something extra - that this is an acronym, which becomes much less obvious if I need to read it like a word first, then backtrack to figure out if it's actually an acronym.
This is a hardly pain point in my life. I'd value consistency with Apple's Apis over any of the pros listed here. And yes, I'm purposely typing API as Api in this thread 😜 |
I have never seen anyone make the
|
Seems like people are not onboard with this. Closing this until I finish making my PR to change general conventions of Swift guidelines. 😉 |
Summary
This would update the style guide to treat acronyms as normal words within camel case.
No matter what happens, I'll work on a linter rule so we can keep things consistent.
Please read the reasoning below and mark with 👍/👎
Reasoning
Pros:
httpURLRequest
vshttpUrlRequest
Cons:
Reviewers
cc @airbnb/swift-styleguide-maintainers
Please react with 👍/👎 if you agree or disagree with this proposal.