Still working to recover. Please don't edit quite yet.

camel case

From Anarchopedia
(Redirected from CamelCase)
Jump to: navigation, search

CamelCase, camel case or medial capitals is the practice of writing compound words or phrases in which the words are joined without spaces and are capitalized within the compound. The term's name comes from the uppercase "bumps" in the middle of the compound word, suggestive of the humps of a camel. An example is backColor.

There are many other names for this practice, including camelBack, BiCapitalization, InterCaps, InfixCaps, MixedCase, and PolyCaps. CamelCase is a standard identifier naming convention for several programming languages, and has become fashionable in marketing for names of products and companies. Outside these contexts, however, CamelCase is rarely used in formal written English, and most style guides recommend against it.

Variations and synonyms[edit]

There are two common varieties of CamelCase, distinguished by their handling of the initial letter of what would otherwise be the first of separate words. Where the first letter is capitalized is commonly called UpperCamelCase or PascalCase [1] [2]. Where the first letter is left in lowercase is commonly called lowerCamelCase.[unverified] For clarity, this article will use the terms UpperCamelCase and lowerCamelCase, respectively.

   camelCaseLooksLikeThis
   lowerCamelCaseLooksTheSame
   UpperCamelCaseLooksLikeThis

Other synonyms include:

  • BumpyCaps
  • BumpyCase
  • CamelCaps
  • camelCase
  • CamelHumpedWord
  • CapWords in Python (reference)
  • mixedCase (for lowerCamelCase) in Python (reference)
  • ClCl (Capital-lower Capital-lower) and sometimes ClC
  • HumpBackNotation
  • InterCaps
  • InternalCapitalization
  • Multicapitalization
  • NerdCaps
  • WordCase
  • WordMixing
  • WordsStrungTogether or WordsRunTogether

Similar terms[edit]

The term StudlyCaps is similar — but not necessarily identical — to CamelCase. It is sometimes used in reference to CamelCase but can also refer to random mixed capitalisation (as in "MiXeD CaPitALiSaTioN") as popularly used in online culture.

The term Title Case is also similar, but Title Case has spaces between the words. Title Case also doesn't usually uppercase certain small words such as 'and' and 'the'.[3][4][5]

Coding style[edit]

Internal capitalization is sometimes recommended by the coding style guidelines written for source code (e.g., the Mesa programming language and the Java programming language). The recommendations contained in some of these guidelines are supported by static analysis tools that check source code for adherence.

These recommendations often distinguish between UpperCamelCase and lowerCamelCase, typically specifying which variety should be used for specific kinds of entities: variables, record fields, methods, procedures, types, etc.

The Java coding style dictates that UpperCamelCase be used for classes, and lowerCamelCase be used for instances and methods. The original Hungarian notation for programming specifies that a lowercase abbreviation for the "usage type" (not data type) should prefix all variable names, with the remainder of the name in UpperCamelCase; as such it is a form of lowerCamelCase. CamelCase is the official convention for file names in Java and of the Amiga personal computers.

Microsoft .NET recommends CamelCase.[6]

The NIEM registry requires that XML Data Elements use UpperCamelCase and XML Attributes use lowerCamelCase.

Some wikis, especially the earlier ones, use CamelCase to mark words that should be automatically linked. JSPWiki is such a system. In many modern wikis (such as Wikipedia and other MediaWiki-based wikis) this convention was abandoned in favor of explicit link markup, for example, with [[…]].

History[edit]

Early uses[edit]

CamelCase has been sporadically used since ancient times, for example as a traditional spelling style for certain surnames, such as in Scottish names like MacLean ("son of Gilian") and Hiberno-Norman names like FitzGerald (originally, "son of Gerald"). Often, names from French origin are spelt this way in English, though in French there always is a space and the preposition may or may not be capitalized depending on specifics of each name, e.g. the DuPont company was founded by Eleuthère Irénée du Pont ("of/from the bridge"). In the mid-20th century, it was used occasionally for product trademarks, such as CinemaScope and VistaVision, rival widescreen movie formats introduced in the 1950s. CamelCase also occurred sometimes in acronyms like DoD, or technical codes and formulas like HeLa (1983). CamelCase has also been used to transliterate acronyms from alphabets such as Cyrillic where two letters may be required to represent a single character of the original alphabet. An example of this is the DShK (Cyrillic: ДШК).

However, the use of CamelCase became widespread only in the 1970s or 1980s, when it was adopted as a standard or alternative naming convention for multi-word identifiers in several programming languages. There are various possible origins, and it may have developed independently from multiple sources. Some of these theories are described below.

Background: multi-word identifiers[edit]

In programs of any significant size, there is a need for descriptive (hence multi-word) identifiers, like "previous balance" or "end of file". However, spaces are not typically permitted inside identifiers, as they are treated as delimiters between tokens. Writing the words together as in "endoffile" is not satisfactory because the names often become unreadable. Therefore, the programming language COBOL allowed a hyphen ("-") to be used between words of compound identifiers, as in "END-OF-FILE".

Most languages, however, interpret the hyphen as a subtraction operator and do not allow the character in identifier names. The common punched card character sets of the time had no lower-case letters and no special character that would be adequate as a word separator in identifiers. However, by the late 1960s the ASCII character set standard had been established, allowing the designers of the C language to adopt the underscore character "_" as a word joiner. Underscore-separated compounds like "end_of_file" are still prevalent in C programs and libraries.

CamelCase is by no means universal. Users of several modern programming languages, notably those in the Lisp and Forth families, nearly always use hyphens. Among the reasons sometimes given are that doing so does not require shifting on most keyboards, and that the words are more readable when they are separated.

The "Lazy Programmer" origin[edit]

One explanation of the origins of CamelCase in computing claims that the style originated within the culture of C programmers and hackers, who found it more convenient than the standard underscore-based style.

On most keyboards, the underscore key is inconveniently placed. Additionally, in some fonts the underscore character can be confused with a minus sign; it can be overlooked because it falls below the string of characters, or it can be lost entirely when displayed or printed underlined, or when printed on a dot-matrix printer with a defective pin or misaligned ribbon. Moreover, compiler limits on identifier length and the small computer displays available in the 1970s worked together to encourage brevity. Many programmers thus chose to use CamelCase for it yielded legible compound names with fewer keystrokes and fewer characters. One example is the XML DOM function document.getElementById("element"). Hungarian Notation is an extension of this style.

The "Paranoid Programmer" origin[edit]

Template:original research

Programmers working in the tradition of linkage oriented languages, especially the Unix C tradition (and later C++), had many concerns to address. Early Unix systems (and early personal computers in general) provided linkage models where external identifiers were distinguished to a short length, often as few as the initial eight characters. Many clashes were possible within the external identifier linkage space which potentially mingles code generated by various high level compilers, runtime libraries required by each of these compilers, compiler generated helper functions, and program startup code, of which some fraction was inevitably compiled from system assembly language. Within this collision domain the underscore character quickly became entrenched as the primary mechanism for differentiating the external linkage space. It was common practice for C compilers to prepend a leading underscore to all external scope program identifiers to avert clashes with contributions from runtime language support. Furthermore, when the C/C++ compiler needed to introduce names into external linkage as part of the translation process, these names were often distinguished with some combination of multiple leading or trailing underscores.

This practice was later codified as part of the C and C++ language standards, in which the use of leading underscores was reserved for the implementation.

A second, independent collision domain was the C preprocessor. The C language preprocessor is unusual in that it does not respect any language-defined scoping model or reserved namespace, not even C language keywords. This problem was generally addressed by writing macros in macro case which mostly mixes upper case letters with dividing underscores:

#define OPEN_FILE_LIMIT  (15)  

Once again the implementation must often supply hidden macros, and once again dressing up these "hidden behind the scenes" identifiers with multiple leading or trailing underscores became accepted practice. As this practice became pervasive on both levels, the underscore gained a cognitive association with system level programming, hidden technicalities, and the messy entrails of language support.

The C language linkage model further complicated matters by not supporting a strong module-level linkage model. In the C language the concept of module was initially rather loose. There was no language distinction between function names intended for linkage to other compilation units and function names intended only for use within a single compilation unit to simplify the implementation. The C language provides the static keyword which makes it possible to hide names from external linkage, but this was rarely employed, as it also obscured these names from most runtime debugging tools[unverified].

A common early convention was to use names (often prosaic) consisting mostly of lower case letters and underscores for names in external linkage not intended for use by other translation units such as a local function named count_obscure_piddly_flags and camel case or some variant for primary application calls such as EditSaveFile[unverified].

The "Alto Keyboard" origin[edit]

Another explanation is that CamelCase started at Xerox PARC around 1978, with the Mesa programming language developed for the Xerox Alto computer. This machine lacked an underscore key, and the hyphen and space characters were not permitted in identifiers, leaving CamelCase as the only viable scheme for readable multiword names. The PARC Mesa Language Manual (1979) included a coding standard with specific rules for Upper- and lowerCamelCase which was strictly followed by the Mesa libraries and the Alto operating system.

The Smalltalk language, which was developed originally on the Alto and became quite popular in the early 1980s, may have been instrumental in spreading the style outside PARC. CamelCase was also used by convention for many names in the PostScript page description language (invented by Adobe Systems founder and ex-PARC scientist John Warnock). Further boost was provided by Niklaus Wirth — the inventor of Pascal — who acquired a taste for CamelCase during a sabbatical at PARC, and used it in Modula, his next programming language.

Spread to mainstream usage[edit]

During the same period in which personal computers exposed hacker culture to a more mainstream audience in the 1980s and 1990s, CamelCase became fashionable for corporate trade names, first in computer-related fields but later expanding further into the mainstream. The city of SeaTac, Washington is the first city officially spelled in CamelCase. Though not technically CamelCase, during the dot-com bubble of in the late 1990s, in particular, the lowercase prefixes "e" (for "electronic") and "i" (for "Internet", "information", or perhaps "intelligent") became quite common. Examples ranging from the 1960s to the 2000s give a history of the spread of the usage:

This fashion has become so pervasive that it is often incorrectly applied to names that do not use it officially, as in TransAmerica (Transamerica), FireFox (Firefox), UseNet (Usenet), GameBoy (Game Boy), MacWorld (Macworld), and CalTech (Caltech).

History of the name[edit]

The original name of the practice, used in media studies, grammars, and the Oxford English Dictionary, was "medial capitals". The fancier names such as "InterCaps", "CamelCase", and variations thereof are relatively recent, and seem more common in computer-related communities.

The earliest known occurrence of InterCaps on Usenet is in an April 1990 post to the group alt.folklore.computers by Avi Rappoport [8], with BiCapitalization appearing slightly later in a 1991 post by Eric S. Raymond to the same group [9]. The earliest use of the name "CamelCase" occurs in 1995, in a post by Newton Love. [10]. "With the advent of programming languages having these sorts of constructs, the humpiness of the style made me call it HumpyCase at first, before I settled on CamelCase. I had been calling it CamelCase for years," said Newton, [11] "The citation above was just the first time I had used the name on USENET."

The name CamelCase is not related to the "Camel book" (Programming Perl), which uses all-lowercase identifiers with underscores in its sample code.

Usage in other languages[edit]

CamelCase has been used in languages other than English for a variety of purposes, such as the transcription of Tibetan names like rLobsang, or names of Bantu languages like kiSwahili or isiZulu. In French, abbreviations such as OuLiPo (1960) were favored for a time as alternatives to acronyms. In Irish orthography, when a word has undergone eclipsis, only the letter corresponding to the unmutated form is capitalized; for example Gaillimh means "Galway", and its initial letter is the one capitalized in i nGaillimh "in Galway". The same holds when t or h is prefixed to a capital letter: an tAlbanach "the Scottish person" (from Albanach "Scottish person"), an tSín "China" (cf. Síneach "Chinese person"), go hÉireann "to Ireland" (from Éire "Ireland).

German[edit]

In the German language, nouns carry a grammatical gender, which as for words indicating the role of someone, like job titles, is mostly masculine. A capital I marking the beginning of the feminine title suffix "In" (and "Innen" for plural) has since the 80s become customary in those German language media circulating among a feminist or left-wing readership as a political spelling to emphasize the inclusion of females. Example: LeserInnenbriefe instead of Leserbriefe (Letters from readers).

Italian[edit]

In formal Italian writing, the pronouns referring to the reader (Le, Vi) used to be written in uppercase; the same convention was used when referring to God. This could be also extended to the enclitic forms of these pronouns; example: Cogliamo l'occasione per porgerLe distinti saluti (which could be approximately translated with In the meantime please accept our best wishes). This usage however is becoming less and less common.

See also[edit]

References[edit]

External links[edit]

This article contains content from Wikipedia. Current versions of the GNU FDL article CamelCase on WP may contain information useful to the improvement of this article WP