Class names with acronyms

500 views
Skip to first unread message

Christoph Schwering

unread,
Nov 3, 2022, 7:56:56 PM11/3/22
to cxx
Hi!

Do we have a naming rule about acronyms and abbreviations in class names?

I recall a guideline along the lines of "the first acronym in a class name has to be capitalized", but I can't find it anywhere.

There are certainly many examples following this pattern, e.g., JSONParser, GURL, GUID, SharedURLLoaderFactory, (in Blink) HTMLInputElement. On the other hand, there are many classes named "Id" with a lowercase "d".

Thanks,
Chris

--

Google Germany GmbH

Erika-Mann-Straße 33

80636 München


Geschäftsführer: Paul Manicle, Liana Sebastian

Registergericht und -nummer: Hamburg, HRB 86891

Sitz der Gesellschaft: Hamburg


Diese E-Mail ist vertraulich. Falls Sie diese fälschlicherweise erhalten haben sollten, leiten Sie diese bitte nicht an jemand anderes weiter, löschen Sie alle Kopien und Anhänge davon und lassen Sie mich bitte wissen, dass die E-Mail an die falsche Person gesendet wurde. 


This email is confidential. If you received this communication by mistake, please don't forward it to anyone else, please erase all copies and attachments, and please let me know that it has gone to the wrong person.


Daniel Cheng

unread,
Nov 3, 2022, 8:01:04 PM11/3/22
to Christoph Schwering, cxx

For the purposes of the naming rules below, a "word" is anything that you would write in English without internal spaces. This includes abbreviations, such as acronyms and initialisms. For names written in mixed case (also sometimes referred to as "camel case" or "Pascal case"), in which the first letter of each word is capitalized, prefer to capitalize abbreviations as single words, e.g., StartRpc() rather than StartRPC().

We have a lot of things that predated this style guide rule, so you'll see a bunch of the old style where the entire acronym is capitalized, but newer code is supposed to follow the updated guidance.

Daniel


--
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAN-ZcvHYq-q-yqyrLv_%2BfQqV%3DD4cgpXf%2B2o5%3DfVwAxMhN8AXHg%40mail.gmail.com.

Christoph Schwering

unread,
Nov 3, 2022, 8:55:49 PM11/3/22
to Daniel Cheng, cxx
Thanks a lot! Not sure how I missed that paragraph so many times.

Jeremy Roman

unread,
Nov 4, 2022, 3:04:49 PM11/4/22
to Christoph Schwering, Daniel Cheng, cxx
Blink is an especially notable counterexample, in large part because the web-exposed names do the opposite (e.g. HTMLBRElement), though even there there are exceptions-to-the-exceptions (e.g., XMLHttpRequest, which isn't even internally consistent).

Reply all
Reply to author
Forward
0 new messages