-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
Name convention for acryonims #279
Comments
One advantage of namespacing the core libs that's not as apparent yet might be documentation. Having too many constants in the toplevel makes it harder to write a nice documentation interface for that allows to easily find everything there is about a certain section of the standard library. On the subjective side, having everything in one namespace doesn't feel very "clean" to me. And I don't mind the colons that much. So |
Personally I prefer XML, JSON, JTTP, YAML. They are abbreviations. It is correct to write them this way. |
If I am not mistaken, the double colons are designated to represent a syntactic feature of Crystal in cases such as As for the choice of capitalization, I would say that in my opinion the most sensible choice is to adhere to the real acronym as this makes the reference to the external software-concept more intuitively obvious (so for example, I prefer JSON simply because this is how the format is officially known). |
Thanks you all for your answers!! I'm now more convinced to name things as |
If we set a constant/module/class name convention we also should set an accompanying path/filename convention. Ruby failed to do that, leading to things like I'd vote for making the Rails style convention:
I think that gives the best compromise between retaining information and what people are used to from the Ruby world. For completeness sake there's the argument to do |
+1 If we have to unify the names I prefer to uppercase them everywhere. Actually I don't remember exactly why we decided to go with the spelling rule :) |
@jhass Totally agree, consistent naming is a good idea. |
Then it's decided. I'll make the (breaking change) soon. Better now than later :-) |
+1 for upcase and consistency. As @jhass I don't like case in my filenames. |
@jhass about |
I think it would make sense at this point to set those conventions into stone by for example writing them into a CONTRIBUTING.md into the repo ;) |
@jhass Yes, or a style guide. Now that we have this name convention we have another small inconsistency in the std. We have: require "net/http"
HTTP::Client.new ... We also have Socket and TCPSocket classes. Should we...
|
I'd go for dropping the net namespace. Having |
Oh, I got really late to this party, and I guess a breaking rename again will be hard to argue for? I definitely think PascalCased acronyms are much more readable, thus more easily understandable and readable code. I would beg on my knees for |
More arguments for PascalCase
|
I'm starting to agree with @ozra and @mirek . I believe pascal case for acronyms is easier to read and write and makes names more consistent and easier to figure out in case you need to use them. I always liked how this is handled in C#, basically use pascal case, and the standard library is very consistent about this. While searching this I even found a code convention guide for acronyms right in the docs. I was about to say that we should start using this convention, using aliases for the current names to make upgrade easier and slower, but... looking at the standard library, modules as namespaces are used very well. We have This way is maybe better because it preserves the original name of the acronym, so it's more familiar ( So, what we can do and encourage is pascal case when names are combined into a single name, but otherwise use acronyms as module names and use them as namespaces. |
I agree that there is something strangely nice about capitals in ruby'ish syntax, this lean chubbiness that goes well with begin? end blocks and just feels right. Should we just change |
Yes changing |
Right now we have:
Xml::Node
,Xml::Document
, ...Json::Parser
,Json::Lexer
, ...HTTP::Client
,HTTP::Request
, ...Yaml::Parser
, ...Our original idea was to use upcase for things that you normally say letter by letter, like XML and HTTP, and use downcase for things that are pronounced like a name (json is pronounced "jason", yaml is pronounced "yaml", etc.).
We are currently following this rule, except for Xml, probably because we thought about that rule later in time. Now I'm not sure about this. I think
Http::Client
feels more lightweight thanHTTP::Client
. Maybe using downcase everywhere is better: you spend less time holding shift, and you can better distinguish where the next "word" starts when not using colons.As a separate issue, I find it easier to type
HttpClient
thanHttp::Client
, orJsonParser
thanJson::Parser
. In .Net for example they have a typeDateTime
and anotherDateTimeKind
that are related. They also have anHttpClient
class. Right now we haveTime
andTime::Kind
. I find it a bit annoying to type those two colons. So maybe we should drop them in these cases. Who else is going to define aJsonParser
or anHttpClient
type at the top level? The std should be as pleasant to use as possible.We should decide on this now that the language is still in version 0.x, where we can make breaking changes.
The text was updated successfully, but these errors were encountered: