CamelCase
Bicapitalization or camel case (frequently written CamelCase) is the practice of writing compound wordss or phrases where the terms are joined without spacess, and every term is capitalized. The name comes from a supposed resemblance between the bumpy outline of the compound word and the humps of a camel.CamelCase synonyms include:
- MixedCase
- InterCaps
- NerdCaps
- BiCapitalized
- BumpyCase
- HumpBackNotation
- InternalCapitalization
- StudlyCaps
- CamelHumpedWord
- WordsStrungTogether or WordsRunTogether
- CapWords (in Python [1]).
| Table of contents |
|
2 The spread of CamelCase 3 Variations on CamelCase 4 See also |
COBOL, the first major programming language to support compound names, used hyphen "-" between terms, e.g. "END-OF-FILE. It should be noted that the common punched card character sets of the time had no lower-case letters and no other special character that could be used for the purpose. The later "algebraic" languages (such as C), which needed the hyphen for the minus operator, adopted the underscore character "_" (which was mandated by the new ASCII standard) as word joiner. Underscore-separated compounds like "end_of_file" are still prevalent in C programs and libraries.
However, in most keyboards the underscore key is inconveniently placed, and must be typed with the help of the SHIFT key; moreover, in many fonts the underscore character is easily confused with a blank space or with a minus sign. So — according to this theory — many programmers choose to use CamelCase instead, because it yielded legible compound names with fewer keystrokes.
Origins
Programmers' choice
It has been claimed that CamelCase originated within the culture of C programmers and hackers. In programs of any significant size there is a need for descriptive (hence multi-word) identifiers, like "previous balance" or "end of file". Allowing spaces within identifiers would cause problems for compilers, and just writing the words together as in "endoffile" would make the programs unreadable. The Alto keyboard
Another theory is that CamelCase actually started at Xerox PARC around 1978, with the Mesa programming language developed for the Xerox Alto computer. This machine lacked an underscore key, so the Mesa libraries and the Alto operating system had to be coded all in CamelCase. The Smalltalk programming language, which was also developed originally on the Alto and became quite popular in the early 1980s, may have been instrumental in spreading the style outside PARC. Another boost was provided by Niklaus Wirth — the inventor of Pascal — who acquired the taste for CamelCase during a sabbatical at PARC, and used it in Modula, his next programming language.The spread of CamelCase
Be that as it may, CamelCase eventually spread via hacker culture into mainstream use and became fashionable for corporate trade names during the popularization of the personal computer in the 1980s and 1990s. Here are some examples:
Variations on CamelCase
In upper CamelCase style, the first letter of every word is written in upper case, as in "TheColourOfTheBar". In lower CamelCase the first word is left uncapitalized, as in "theColourOfTheBar". Coding standards based on CamelCase (like the pioneering Mesa style, or the modern Java style) typically specify which of these variants should be used for specific kinds of entities — variabless, record fields,methodss, procedures, types, etc..