Naming convention for multi-word identifiers with initialisms

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Naming convention for multi-word identifiers with initialisms

Alexander Jones
Occasionally this comes up when deciding on a spelling for something. There are numerous examples in ECMAScript and other Web standards that seem to defy the most uniform convention:

 * `JSON` vs. `Json`
 * `toJSON` vs. `toJson`
 * `XMLHttpRequest` vs. `XmlHttpRequest`
 * `DOMElement` vs. `DomElement`

While it looks initially strange to specifically drop the capital letters on an initialisms like XML, the rule is simple in that it has an obvious machine decoding - a capital letter starts a new word. Thus, translations of identifiers to other case conventions are automatic (so long as numbers never appear at the start of a word). This helps a lot when e.g. generating bindings for IDLs to different languages, or in general interfacing different systems that really, really want to use their own naming conventions.

 * mixed case: `myTlaIdentifierHere`
 * pascal case: `MyTlaIdentifierHere`
 * underscore case: `my_tla_identifier_here`
 * uppercase: `MY_TLA_IDENTIFIER_HERE`
 * kebab case: `my-tla-identifier-here`
 * spaces case: `my tla identifier here`

---

My question is whether there is an existing community recommendation anywhere for naming ECMAScript identifiers. Clearly, when Microsoft devised the name `XMLHttpRequest`, someone was having a difficult time figuring out how to spell adjacent initialisms in PascalCase.

If there is no recommendation, perhaps there should be? Is there any scope for non-normative sections of information like this in the ECMAScript spec?

Thanks

Alex

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Naming convention for multi-word identifiers with initialisms

Domenic Denicola

https://w3ctag.github.io/design-principles/#casing-rules

 

From: es-discuss [mailto:[hidden email]] On Behalf Of Alexander Jones
Sent: Tuesday, July 11, 2017 08:07
To: [hidden email]
Subject: Naming convention for multi-word identifiers with initialisms

 

Occasionally this comes up when deciding on a spelling for something. There are numerous examples in ECMAScript and other Web standards that seem to defy the most uniform convention:

 

 * `JSON` vs. `Json`

 * `toJSON` vs. `toJson`

 * `XMLHttpRequest` vs. `XmlHttpRequest`

 * `DOMElement` vs. `DomElement`

 

While it looks initially strange to specifically drop the capital letters on an initialisms like XML, the rule is simple in that it has an obvious machine decoding - a capital letter starts a new word. Thus, translations of identifiers to other case conventions are automatic (so long as numbers never appear at the start of a word). This helps a lot when e.g. generating bindings for IDLs to different languages, or in general interfacing different systems that really, really want to use their own naming conventions.

 

 * mixed case: `myTlaIdentifierHere`

 * pascal case: `MyTlaIdentifierHere`

 * underscore case: `my_tla_identifier_here`

 * uppercase: `MY_TLA_IDENTIFIER_HERE`

 * kebab case: `my-tla-identifier-here`

 * spaces case: `my tla identifier here`

 

---

 

My question is whether there is an existing community recommendation anywhere for naming ECMAScript identifiers. Clearly, when Microsoft devised the name `XMLHttpRequest`, someone was having a difficult time figuring out how to spell adjacent initialisms in PascalCase.

 

If there is no recommendation, perhaps there should be? Is there any scope for non-normative sections of information like this in the ECMAScript spec?

 

Thanks

 

Alex


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Naming convention for multi-word identifiers with initialisms

Alexander Jones
Thanks for the pointer Dominic - it does make me weep a bit (`HTMLHRElement` u wot) but I'm glad someone wrote it down! (And it seems `XMLHttpRequest` is still in violation...)

The next step is probably something more akin to PEP-8 than a partial codification of existing norms.

On 11 July 2017 at 16:37, Domenic Denicola <[hidden email]> wrote:

https://w3ctag.github.io/design-principles/#casing-rules

 

From: es-discuss [mailto:[hidden email]] On Behalf Of Alexander Jones
Sent: Tuesday, July 11, 2017 08:07
To: [hidden email]
Subject: Naming convention for multi-word identifiers with initialisms

 

Occasionally this comes up when deciding on a spelling for something. There are numerous examples in ECMAScript and other Web standards that seem to defy the most uniform convention:

 

 * `JSON` vs. `Json`

 * `toJSON` vs. `toJson`

 * `XMLHttpRequest` vs. `XmlHttpRequest`

 * `DOMElement` vs. `DomElement`

 

While it looks initially strange to specifically drop the capital letters on an initialisms like XML, the rule is simple in that it has an obvious machine decoding - a capital letter starts a new word. Thus, translations of identifiers to other case conventions are automatic (so long as numbers never appear at the start of a word). This helps a lot when e.g. generating bindings for IDLs to different languages, or in general interfacing different systems that really, really want to use their own naming conventions.

 

 * mixed case: `myTlaIdentifierHere`

 * pascal case: `MyTlaIdentifierHere`

 * underscore case: `my_tla_identifier_here`

 * uppercase: `MY_TLA_IDENTIFIER_HERE`

 * kebab case: `my-tla-identifier-here`

 * spaces case: `my tla identifier here`

 

---

 

My question is whether there is an existing community recommendation anywhere for naming ECMAScript identifiers. Clearly, when Microsoft devised the name `XMLHttpRequest`, someone was having a difficult time figuring out how to spell adjacent initialisms in PascalCase.

 

If there is no recommendation, perhaps there should be? Is there any scope for non-normative sections of information like this in the ECMAScript spec?

 

Thanks

 

Alex



_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Naming convention for multi-word identifiers with initialisms

Alexander Jones
In reply to this post by Alexander Jones
Just for funsies I looked this up - In the interests of honesty I should point out that apparently it was Mozilla who named this `XMLHttpRequest` thing. https://softwareengineering.stackexchange.com/questions/157375/why-does-xmlhttprequest-not-seem-to-follow-a-naming-convention

On 11 July 2017 at 13:07, Alexander Jones <[hidden email]> wrote:
Occasionally this comes up when deciding on a spelling for something. There are numerous examples in ECMAScript and other Web standards that seem to defy the most uniform convention:

 * `JSON` vs. `Json`
 * `toJSON` vs. `toJson`
 * `XMLHttpRequest` vs. `XmlHttpRequest`
 * `DOMElement` vs. `DomElement`

While it looks initially strange to specifically drop the capital letters on an initialisms like XML, the rule is simple in that it has an obvious machine decoding - a capital letter starts a new word. Thus, translations of identifiers to other case conventions are automatic (so long as numbers never appear at the start of a word). This helps a lot when e.g. generating bindings for IDLs to different languages, or in general interfacing different systems that really, really want to use their own naming conventions.

 * mixed case: `myTlaIdentifierHere`
 * pascal case: `MyTlaIdentifierHere`
 * underscore case: `my_tla_identifier_here`
 * uppercase: `MY_TLA_IDENTIFIER_HERE`
 * kebab case: `my-tla-identifier-here`
 * spaces case: `my tla identifier here`

---

My question is whether there is an existing community recommendation anywhere for naming ECMAScript identifiers. Clearly, when Microsoft devised the name `XMLHttpRequest`, someone was having a difficult time figuring out how to spell adjacent initialisms in PascalCase.

If there is no recommendation, perhaps there should be? Is there any scope for non-normative sections of information like this in the ECMAScript spec?

Thanks

Alex


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Naming convention for multi-word identifiers with initialisms

nanto_vi
Microsoft said "XMLHttpRequest" in August 1999 [*1], a month before
feature request for Mozilla [*2].

[*1]
https://web.archive.org/web/19990828184122/http://msdn.microsoft.com/xml/reference/scriptref/XMLHttpRequest_Object.asp
[*2] https://bugzilla.mozilla.org/show_bug.cgi?id=15119

On 2017/07/12 5:53, Alexander Jones wrote:

> Just for funsies I looked this up - In the interests of honesty I should
> point out that apparently it was Mozilla who named this `XMLHttpRequest`
> thing.
> https://softwareengineering.stackexchange.com/questions/157375/why-does-xmlhttprequest-not-seem-to-follow-a-naming-convention
>
> On 11 July 2017 at 13:07, Alexander Jones <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Occasionally this comes up when deciding on a spelling for
>     something. There are numerous examples in ECMAScript and other Web
>     standards that seem to defy the most uniform convention:
>
>       * `JSON` vs. `Json`
>       * `toJSON` vs. `toJson`
>       * `XMLHttpRequest` vs. `XmlHttpRequest`
>       * `DOMElement` vs. `DomElement`
>
>     While it looks initially strange to specifically drop the capital
>     letters on an initialisms like XML, the rule is simple in that it
>     has an obvious machine decoding - a capital letter starts a new
>     word. Thus, translations of identifiers to other case conventions
>     are automatic (so long as numbers never appear at the start of a
>     word). This helps a lot when e.g. generating bindings for IDLs to
>     different languages, or in general interfacing different systems
>     that really, really want to use their own naming conventions.
>
>       * mixed case: `myTlaIdentifierHere`
>       * pascal case: `MyTlaIdentifierHere`
>       * underscore case: `my_tla_identifier_here`
>       * uppercase: `MY_TLA_IDENTIFIER_HERE`
>       * kebab case: `my-tla-identifier-here`
>       * spaces case: `my tla identifier here`
>
>     ---
>
>     My question is whether there is an existing community recommendation
>     anywhere for naming ECMAScript identifiers. Clearly, when Microsoft
>     devised the name `XMLHttpRequest`, someone was having a difficult
>     time figuring out how to spell adjacent initialisms in PascalCase.
>
>     If there is no recommendation, perhaps there should be? Is there any
>     scope for non-normative sections of information like this in the
>     ECMAScript spec?
>
>     Thanks
>
>     Alex
>
>
>
>
> _______________________________________________
> es-discuss mailing list
> [hidden email]
> https://mail.mozilla.org/listinfo/es-discuss
>
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Naming convention for multi-word identifiers with initialisms

Isiah Meadows-2

Regarding naming, ES itself is pretty consistent:

- Types are PascalCase. Ex: WeakMap
- Non-symbol constants are UPPER_SNAKE_CASED. Ex: Number.MAX_SAFE_INTEGER
- Initalisms within names are always lower case if first and not part of a type name, upper case otherwise. Ex: JSON, Date.prototype.toJSON
- Everything else is camelCase. Ex: Symbol.hasInstance, Object.keys

It's the DOM and HTML APIs that are inconsistent, typically for historical reasons.


On Fri, Jul 14, 2017, 03:22 TOYAMA Nao <[hidden email]> wrote:
Microsoft said "XMLHttpRequest" in August 1999 [*1], a month before
feature request for Mozilla [*2].

[*1]
https://web.archive.org/web/19990828184122/http://msdn.microsoft.com/xml/reference/scriptref/XMLHttpRequest_Object.asp
[*2] https://bugzilla.mozilla.org/show_bug.cgi?id=15119

On 2017/07/12 5:53, Alexander Jones wrote:
> Just for funsies I looked this up - In the interests of honesty I should
> point out that apparently it was Mozilla who named this `XMLHttpRequest`
> thing.
> https://softwareengineering.stackexchange.com/questions/157375/why-does-xmlhttprequest-not-seem-to-follow-a-naming-convention
>
> On 11 July 2017 at 13:07, Alexander Jones <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Occasionally this comes up when deciding on a spelling for
>     something. There are numerous examples in ECMAScript and other Web
>     standards that seem to defy the most uniform convention:
>
>       * `JSON` vs. `Json`
>       * `toJSON` vs. `toJson`
>       * `XMLHttpRequest` vs. `XmlHttpRequest`
>       * `DOMElement` vs. `DomElement`
>
>     While it looks initially strange to specifically drop the capital
>     letters on an initialisms like XML, the rule is simple in that it
>     has an obvious machine decoding - a capital letter starts a new
>     word. Thus, translations of identifiers to other case conventions
>     are automatic (so long as numbers never appear at the start of a
>     word). This helps a lot when e.g. generating bindings for IDLs to
>     different languages, or in general interfacing different systems
>     that really, really want to use their own naming conventions.
>
>       * mixed case: `myTlaIdentifierHere`
>       * pascal case: `MyTlaIdentifierHere`
>       * underscore case: `my_tla_identifier_here`
>       * uppercase: `MY_TLA_IDENTIFIER_HERE`
>       * kebab case: `my-tla-identifier-here`
>       * spaces case: `my tla identifier here`
>
>     ---
>
>     My question is whether there is an existing community recommendation
>     anywhere for naming ECMAScript identifiers. Clearly, when Microsoft
>     devised the name `XMLHttpRequest`, someone was having a difficult
>     time figuring out how to spell adjacent initialisms in PascalCase.
>
>     If there is no recommendation, perhaps there should be? Is there any
>     scope for non-normative sections of information like this in the
>     ECMAScript spec?
>
>     Thanks
>
>     Alex
>
>
>
>
> _______________________________________________
> es-discuss mailing list
> [hidden email]
> https://mail.mozilla.org/listinfo/es-discuss
>
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Loading...