Naming convention (programming): Difference between revisions

Content deleted Content added
No edit summary
Bluebot (talk | contribs)
m Fixing C++ links
Line 20:
There is significant disagreement over how much information to put in identifiers. This was driven initially by technical reasons, as some early programming languages only allowed identifiers of a certain length. Thus in the standard C library (C was initially one of those languages), one finds ''atoi'' as the name of a function that converts [[ASCII]] strings to [[integer]]s. In Lisp, one would be more likely to encounter the same function named as ''ascii-to-integer'' or similar. However, the use of shorter identifiers has outlived those technical restrictions, partly as heritage (it continues more commonly in those languages that once had the restrictions), and partly out of ease of use -- it's simply easier to type shorter identifiers, especially when the identifier is used frequently. Those who prefer the longer identifiers argue that the difficulty of typing the longer identifiers is outweighed by the ease of reading code that is more descriptive rather than peppered with impenetrable acronyms and abbreviations.
 
In addition to the issue of length of identifiers in their descriptive capacity, there are also several systems for codifying specific technical aspects of a particular identifier in the name. Perhaps the most well-known is [[Hungarian notation]], which encodes the [[datatype|type]] of a variable in its name. Several more minor conventions are widespread; one example is the convention of naming variables in C and [[C plus plus|C++]] with an initial lowercase letter, and naming user-defined datatypes with an initial capital letter.
 
{{compu-lang-stub}}