Thursday, February 9, 2017

Case in programming identifiers

By no means a comprehensive list, and feel free to give me alternate names or etymologies...
  • LoremIpsum
    • CamelCase
      • This is ambiguous and I really don't recommend using it. camelCase traditionally starts with a lowercase letter (do camels have a hump on their heads?).
    • UpperCamelCase
      • It is exactly the same as camelCase except with the first letter capitalized, and it is unambiguous, but this is rarely used.
    • PascalCase
      • This is the preferred case in Pascal, and I would dearly love for people to consistently call this case PascalCase and just get on with it.
  • Lorem-Ipsum
    • Train-Case
      • This is not something I have seen in the wild, but I have heard of it. A plausible etymology is a series of boxcars linked by couplings which aren't quite at the middle (as in spinal case) or at the ground level (as in snake case) but closer to the ground, over where the wheels would be.
      • Largely superfluous- if you want to use capital/lowercase letters together, then why would your standard use this and not camelCase or PascalCase?
  • lorem-ipsum
    • spinal-case
      • As in, the words seem to be connected centrally through a "spine".
    • kebab-case
      • As in, the words seem to be pierced through the middle by a skewer, as a kebab. Yum!
    • lisp-case
      • This is the preferred case in Lisp, and some refer to it this way, although I would call it somewhat less common these days.
  • loremIpsum
    • camelCase
      • The first word is not capitalized, but the second word is; the increase in case looks like a "hump" and reappears on subsequent words.
      • Common in Java, JavaScript, and myriad other languages.
      • In some shops, it's common to use PascalCase but include a Hungarian prefix lowercased; this results in camelCase (e.g. szCamelCase) identifiers, but Hungarian is also diminishing in popularity.
  • lorem_ipsum
    • snake_case
      • As in, the words are connected along the ground, like a slithering snake... why'd it have to be snakes?
      • Common in C/C++ identifiers, although I don't like it. I prefer camelCase even in C.
  • LOREM_IPSUM
    • SCREAMING_SNAKE_CASE
      • Taken as a modifier of snake case for its use of underscores, the SCREAMING aspect refers to making all letters capitalized, but I haven't heard SCREAMING in any other case- possibly because the idea of a screaming snake is particularly goofy.
      • Universal for C/C++ named constants.
  • LOREM-IPSUM
    • COBOL-CASE
      • COBOL is case insensitive (always capitals), and they don't support many delimiting characters, so hyphen is the best choice.

No comments:

Post a Comment