Naming convention (programming): Difference between revisions

Content deleted Content added
Partial rewrote (more to do)
m Lots of minor edits
Line 10:
== Multiple-word identifiers ==
 
A common recommendation is "Use meaningful identifiers." A single [[word]] may not be as sufficiently meaningful, or specific, as multiple words.
As most [[programming language]]s do not allow the [[whitespace_(computer science)|whitespace]] in identifiers, a method of delimiting each word is needed (to make it easier for subsequent readers to interpret thethose character sequencesequences belonging to each word). There are several in widespread use; each haswith a significant following.
 
One approach is to delimit separate words with a [[alphanumeric|nonalphanumeric]] character. The two characters commonly used for this purpose are the hyphen ('-') and the underscore ('_'), soeg, the two-word name ''two words'' would be represented as ''two-words'' or ''two_words''. The hyphen is used by nearly all programmers ofwriting [[Lisp programming language|LispCobol]], and [[SchemeLisp programming language|SchemeLisp]],. and Many other languages that(eg, permit hyphenslanguages in identifiers.the [[C However,programming manylanguage|C]] otherand languages[[Pascal]] families) reserve the hyphen for use as the [[subtraction]] operator, and so do not permit it in identifiers. This solution is fairlynot widespreadavaialble amongfor programmersuse ofin [[C programming language|C]], [[Perl]], and many [[scripting language]]sidentifiers.
 
An alternate approachisapproach is to indicate word boundaries using capitalization, thus rendering ''two words'' as either ''twoWords'' or ''TwoWords''. ThisThe is calledterm [[CamelCase]], amongis sometimes used to describe otherthis namestechnique.
 
== Information in identifiers ==
Line 25:
==External links==
 
*[http://www.coding-guidelines.com/cbook/sent787.pdf 100 Apage detailedpdf] that uses linguistics and psychology to attempt a cost/benefit analysis of identifier naming issues]
 
{{compu-lang-stub}}