2

Does anyone know of any standards or best practices for dealing with acronyms and initialisms? (PHP and Javascript conventions would be most helpful to me but the reasoning for any language would be hepful)

Examples:

function getXML(){} vs function getXml(){}

or

$userId vs $userID

Your Friend Ken
  • 8,644
  • 3
  • 32
  • 41

2 Answers2

1

The conventions vary in PHP development. The answer to this question will provide examples of different conventions.

I've found that most developers I've worked with follow that later convention:

function getXml() {}

and

$userId

Take a look at this other resource to learn more about PHP coding style conventions.

Community
  • 1
  • 1
MParsons
  • 289
  • 3
  • 15
  • Did you see any references to initialisms in the PSR standards? I was scanning through them before posting here hoping to find examples of initializations. My team all agreed to use PSR for PHP code, but we seem to have differing opinions on initialisms. – Your Friend Ken Apr 17 '16 at 23:02
  • Unfortunately not. Initialisms are a special case that were most likely not specified in the PSR standards due to the concerns addressed in [this post](http://stackoverflow.com/questions/8277355/naming-convention-for-upper-case-abbreviations). – MParsons Apr 17 '16 at 23:13
  • http://php.net/manual/en/class.simplexmlelement.php PHP Classes seems to keep initialisms uppercase – Your Friend Ken Apr 18 '16 at 22:19
  • PHP's classes follow different naming conventions. I found [EventHttpConnection](http://php.net/manual/en/class.eventhttpconnection.php) which uses [Pascal Case](http://c2.com/cgi/wiki?PascalCase), instead of all caps. – MParsons Apr 19 '16 at 01:21
1

There is no universal convention for initialisms and acronyms in JavaScript.

Some examples:

GG.
  • 21,083
  • 14
  • 84
  • 130