FACTOID # 50: Libya is the only country with a single-coloured flag.
 
 Home   Encyclopedia   Statistics   Countries A-Z   Flags   Maps   Education   Forum   FAQ   About 
 
WHAT'S NEW
RECENT ARTICLES
More Recent Articles »
 

FACTS & STATISTICS    Simple view

  1. Select countries to view: (hold down Control key and click to select several)

     

     

    Compare:

     

     

  1. Select fact or statistic: (* = graphable)

     

     

     

  2. (OPTIONAL) Compare to statistic: (both need to be graphable)

     

     

     

  3. View result as:

     

       
(OR) SEARCH ALL encyclopedia, stats & forums:   

Encyclopedia > Naming conventions (programming)

In computer programming, a naming convention is a set of rules for choosing the character sequence to be used for identifiers in source code and documentation. A computer program is a collection of instructions that describe a task, or set of tasks, to be carried out by a computer. ... A naming convention is an attempt to systematize names in a field so they unambiguously convey similar information in a similar manner. ... Identifiers (IDs) are lexical tokens that name entities. ... Source code (commonly just source or code) is any series of statements written in some human-readable computer programming language. ...


Reasons for using a naming convention (as opposed to allowing programmers to choose any character sequence) include the following: A programmer or software developer is someone who programs computers, that is, one who writes computer software. ...

  • to make source code easier to read and understand with less effort;
  • to enhance source code appearance (for example, by disallowing overly long names or abbreviations);

The choice of naming conventions can be an enormously controversial issue, with partisans of each holding theirs to be the best and others to be inferior. Colloquially, this is said to be a matter of "religion" (see the Jargon file article on this matter).

Contents

Potential benefits

Some of the potential benefits that can be obtained by adopting a naming convention include the following:

  • to provide additional information (ie, metadata) about the use to which an identifier is put;
  • to help formalize expectations and promote consistency within a development team;
  • to enable the use of automated refactoring or search and replace tools with minimal potential for error;
  • to enhance clarity in cases of potential ambiguity;
  • to enhance the aesthetic and professional appearance of work product (for example, by disallowing overly long names, comical or "cute" names, or abbreviations); and
  • to help avoid "naming collisions" that might occur when the work product of different organizations is combined (see also: namespaces)

Metadata is data about data. ... Refactoring is the process of rewriting a computer program or other material to improve its structure or readability, while explicitly keeping its meaning or behavior. ... A namespace is a context in which a group of one or more identifiers might exist. ...

Challenges

The choice of naming conventions (and the extent to which they are enforced) is often a contentious issue, with partisans holding their viewpoint to be the best and others to be inferior.


Moreover, even with known and well-defined naming conventions in place, some organizations may fail to consistently adhere to them, causing inconsistency and confusion.


These challenges may be exacerbated if the naming convention rules are internally inconsistent, arbitrary, difficult to remember, or otherwise perceived as more burdensome than beneficial.


Business value of naming conventions

Although largely hidden from the view of most business users, well-chosen identifiers make it significantly easier for subsequent generations of analysts and developers to understand what the system is doing and how to fix or extend the source code for new business needs. Source code (commonly just source or code) is any series of statements written in some human-readable computer programming language. ...


For example, although the following:

 a = b * c 

is syntactically correct, it is entirely opaque as to intent or meaning. Contrast this with: For other uses, see Syntax (disambiguation). ...

 weekly_pay = hours_worked * pay_rate 

which implies the intent and meaning of the source code, at least to those familiar with the underlying context of the application.


Common elements

The exact rules of a naming convention depend on the context in which they are employed. Nevertheless, there are several common elements that influence most if not all naming conventions in common use today.


Length of identifiers

A fundamental element of all naming conventions are the rules related to identifier length (i.e., the finite number of individual characters allowed in an identifier). Some rules dictate a fixed numerical bound, while others specify less precise heuristics or guidelines.


Identifier length rules are routinely contested in practice, and subject to much debate academically.


Some considerations:

  • shorter identifiers may be preferred as more expedient, because they are easier to type
  • extremely short identifiers (such as 'i' or 'j') are very difficult to uniquely distinguish using automated search and replace tools
  • longer identifiers may be preferred because short identifiers cannot encode enough information or appear too cryptic
  • longer identifiers may be disfavored because of visual clutter

It is an open research issue whether programmers prefer shorter identifiers because they are easier to type, or think up, than longer identifiers, or because in many situations a longer identifier simply clutters the visible code and provides no perceived additional benefit.


Brevity in programming could be in part attributed to early linkers which required variable names to be restricted to 6 characters in order to save memory. Figure of the linking process, where object files and static libraries are assembled into a new library or executable. ...


Letter case and numerals

Some naming conventions limit whether letters may appear in uppercase or lowercase. Other conventions do not restrict letter case, but attach a well-defined interpretation based on letter case. Some naming conventions specify whether alphabetic, numeric, or alphanumeric characters may be used, and if so, in what sequence.


Multiple-word identifiers

A common recommendation is "Use meaningful identifiers." A single word may not be as meaningful, or specific, as multiple words. Consequently, some naming conventions specify rules for the treatment of "compound" identifiers containing more than one word. For other uses, see Word (disambiguation). ...


Word boundaries

As most programming languages do not allow whitespace in identifiers, a method of delimiting each word is needed (to make it easier for subsequent readers to interpret which characters belong to which word). A programming language is an artificial language that can be used to control the behavior of a machine, particularly a computer. ... For other uses, see white space. ...


Delimiter-separated words: One approach is to delimit separate words with a nonalphanumeric character. The two characters commonly used for this purpose are the hyphen ('-') and the underscore ('_'), eg, the two-word name two words would be represented as two-words or two_words. The hyphen is used by nearly all programmers writing Cobol and Lisp; it is also common for selector names in Cascading Style Sheets. Many other languages (eg, languages in the C and Pascal families) reserve the hyphen for use as the subtraction operator, and so it is not available for use in identifiers. Also, delimiter separated words may cause conflicts or unexpected behavior when source code is manipulated using a text editor IDE or other processing tool. Delimiters are marks which are used to seperate subfields of data. ... Generally speaking, the term alphanumeric refers to anything that consists of only letters and numbers. ... COBOL (pronounced //) is a third-generation programming language, and one of the oldest programming languages still in active use. ... Lisp is a family of computer programming languages with a long history and a distinctive fully-parenthesized syntax. ... In web development, Cascading Style Sheets (CSS) is a stylesheet language used to describe the presentation of a document written in a markup language. ... C is a general-purpose, block structured, procedural, imperative computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system. ... Pascal is an imperative computer programming language, developed in 1970 by Niklaus Wirth as a language particularly suitable for structured programming. ... 5 - 2 = 3 (verbally, five minus two equals three) An example problem Subtraction is one of the four basic arithmetic operations; it is essentially the opposite of addition. ... Notepad is the standard text editor for Microsoft Windows A text editor is a piece of computer software for editing plain text. ... Binomial name Leuciscus idus Linnaeus, 1758 The Ide or Orfe, Leuciscus idus, is a freshwater fish of the family Cyprinidae found across northern Europe and Asia. ...


Letter-case separated words: An alternate approach is to indicate word boundaries using capitalization, thus rendering two words as either twoWords or TwoWords. The term CamelCase (or camelCase) is sometimes used to describe this technique. This article does not cite any references or sources. ...


Metadata and hybrid conventions

Some naming conventions represent rules or requirements that go beyond the requirements of a specific project or problem domain, and instead reflect a greater over-arching set of principles defined by the software architecture, underlying programming language or other kind of cross-project methodology. The software architecture of a program or computing system is the structure or structures of the system, which comprise software elements, the externally visible properties of those elements, and the relationships between them. ... A programming language is an artificial language that can be used to control the behavior of a machine, particularly a computer. ...


Hungarian notation

  • Perhaps the most well-known is Hungarian notation, which encodes either the purpose ("Apps Hungarian") or the type ("Systems Hungarian") of a variable in its name [1].

Hungarian notation is a naming convention in computer programming, in which the name of a variable indicates its type or intended use. ... In computer science, a datatype or data type (often simply a type) is a name or label for a set of values and some operations which one can perform on that set of values. ...

Positional Notation

A style used for very short (8 characters and less) could be: LCCIIL01, where LC would be the application (Letters of Credit), C for COBOL, IIL for the particular process subset, and the 01 a sequence number.


This sort of convention is still in active use in mainframes dependent upon JCL and is also seen in the 8.3 (maximum 8 characters with period separator followed by 3 character file type) MS-DOS style. Job Control Language (JCL) is a scripting language used on IBM mainframe operating systems to instruct the Job Entry Subsystem (that is, JES2 or JES3) on how to run a batch program or start a subsystem. ...


Composite word scheme (OF Language)

One of the earliest published convention systems was IBM's "OF Language" documented in a 1980s IMS (Information Management System) manual [citation needed]. Information Management System (IMS) is a joint hierarchical database and information management system. ...


It detailed the PRIME-MODIFIER-CLASS word scheme, which consisted of names like "CUST-ACT-NO" to indicate "customer account number".


PRIME words were meant to indicate major "entities" of interest to a system.


MODIFIER words were used for additional refinement, qualification and readability.


CLASS words ideally would be a very short list of data types relevant to a particular application. Common CLASS words might be: NO (number), ID (identifier), TXT (text), AMT (amount), QTY (quantity), FL (flag), CD (code), W (work) and so forth. In practice, the available CLASS words would be a list of less than two dozen terms.


CLASS words, typically positioned on the right (suffix), served much the same purpose as Hungarian notation prefixes. Hungarian notation is a naming convention in computer programming, in which the name of a variable indicates its type or intended use. ...


The purpose of CLASS words, in addition to consistency, was to specify to the programmer the data type of a particular data field. Prior to the acceptance of BOOLEAN (two values only) fields, FL (flag) would indicate a field with only two possible values. A data type is a constraint placed upon the interpretation of data in a type system in computer programming. ...


Language-specific conventions

C and C++ languages

  • In C and C++, keywords and standard library identifiers are mostly lowercase. Identifiers representing macros are, by convention, written using only upper case letters (this is related to the convention in many programming languages of using all-upper-case identifiers for constants). Names beginning with double underscore or an underscore and a capital letter are reserved for implementation (compiler, standard library) and should be not used (e.g. __reserved or _Reserved).

C++ (pronounced see plus plus, IPA: ) is a general-purpose programming language with high-level and low-level capabilities. ... In computer programming, a keyword is a word or identifier that has a particular meaning to the programming language. ... In C++, the Standard Library is a collection of classes and functions, which are written in the core language. ... The C preprocessor (cpp) is the preprocessor for the C programming language. ... A diagram of the operation of a typical multi-language, multi-target compiler. ...

Java language

  • In Java, very strong conventions established from the beginning by the language's originators require classes and variables to be capitalised differently. Thus, to a Java programmer, widget.expand() and Widget.expand() imply significantly different behaviour, even without prior knowledge of the Widget class and despite the fact that the compiler enforces no such rules.

“Java language” redirects here. ... Classes can refer to: social class scientific classification class (object-oriented programming) a subject in school see also class. ... In computer science and mathematics, a variable is a symbol denoting a quantity or symbolic representation. ...

Visual Basic, VB.NET and BASIC languages

  • Traditionally, Basic does not implement the mandatory case-sensitivity that the C-type languages do, and the IDE often provides on-the-spot variable identification. Hence Visual Basic naming conventions tend to rest on what is most human-readable, as opposed to providing information about the identifier itself. For instance, lpszMyString in C would just become MyString in Visual Basic, and widget.expand() would mean the same as Widget.expand().

Look up C, c in Wiktionary, the free dictionary. ...

See also

In general, a namespace is an abstract container, which is or could be filled by names, or technical terms, or words, and these represent (stand for) real-world things. ... A namespace is a context in which a group of one or more identifiers might exist. ...

External links


  Results from FactBites:
 
Naming conventions (programming) - Wikipedia, the free encyclopedia (1295 words)
In computer programming, a naming convention is a set of rules for choosing the character sequence to be used for identifiers in source code and documentation.
Some naming conventions represent rules or requirements that go beyond the requirements of a specific project or problem domain, and instead reflect a greater over-arching set of principles defined by the software architecture, underlying programming language or other kind of cross-project methodology.
This sort of convention is still in active use in mainframes dependent upon JCL and is also seen in the 8.3 (maximum 8 characters with period separator followed by 3 character file type) MS-DOS style.
  More results at FactBites »


 

COMMENTARY     


Share your thoughts, questions and commentary here
Your name
Your comments
Please enter the 5-letter protection code

Want to know more?
Search encyclopedia, statistics and forums:

 


Lesson Plans | Student Area | Student FAQ | Reviews | Press Releases |  Feeds | Contact
The Wikipedia article included on this page is licensed under the GFDL.
Images may be subject to relevant owners' copyright.
All other elements are (c) copyright NationMaster.com 2003-5. All Rights Reserved.
Usage implies agreement with terms.