In
computer programming
Computer programming or coding is the composition of sequences of instructions, called computer program, programs, that computers can follow to perform tasks. It involves designing and implementing algorithms, step-by-step specifications of proc ...
, a name collision is the
nomenclature
Nomenclature (, ) is a system of names or terms, or the rules for forming these terms in a particular field of arts or sciences. (The theoretical field studying nomenclature is sometimes referred to as ''onymology'' or ''taxonymy'' ). The principl ...
problem that occurs when the same
variable name is used for different things in two separate areas that are joined, merged, or otherwise go from occupying separate
namespace
In computing, a namespace is a set of signs (''names'') that are used to identify and refer to objects of various kinds. A namespace ensures that all of a given set of objects have unique names so that they can be easily identified.
Namespaces ...
s to sharing one. As with the
collision of other
identifier
An identifier is a name that identifies (that is, labels the identity of) either a unique object or a unique ''class'' of objects, where the "object" or class may be an idea, person, physical countable object (or class thereof), or physical mass ...
s, it must be resolved in some way for the new
software
Software consists of computer programs that instruct the Execution (computing), execution of a computer. Software also includes design documents and specifications.
The history of software is closely tied to the development of digital comput ...
(such as a
mashup) to work right.
[
"Getting Started" (lesson for C++), ]Brown University
Brown University is a Private university, private Ivy League research university in Providence, Rhode Island, United States. It is the List of colonial colleges, seventh-oldest institution of higher education in the US, founded in 1764 as the ' ...
,
Computer Science Dept., January 2000 (in text as "Jan 2000"),
pages 5-6, webpage (PDF):
CS-Brown-Cpp
Problems of name collision, and methods to avoid them, are a common issue in an introductory level analysis of
computer languages, such as for
C++.
[
__TOC__
]
History
The term "name collision" has been used in computer science for more than three decades, when referring to names in various classification systems.[
"Name collision in multiple classification hierarchies",
Portal ACM (]Association for Computing Machinery
The Association for Computing Machinery (ACM) is a US-based international learned society for computing. It was founded in 1947 and is the world's largest scientific and educational computing society. The ACM is a non-profit professional membe ...
),
by J.L. Knudsen, 1988, webpage:
Portal-ACM-607
Avoiding name collisions
There are several techniques for avoiding name collisions, including the use of:
* ''namespace
In computing, a namespace is a set of signs (''names'') that are used to identify and refer to objects of various kinds. A namespace ensures that all of a given set of objects have unique names so that they can be easily identified.
Namespaces ...
s'' - to qualify each name within a separate name group, so that the totally qualified names differ from each other.[
* ''renaming'' - to change the name of one item (typically the one used less often) into some other name.
* ''prefixing'' - putting unique characters before the names so that the names differ and further name collisions are unlikely to happen by accident.
]
See also
* Local variables, variable data items that are local to a module
* Name mangling
In compiler construction, name mangling (also called name decoration) is a technique used to solve various problems caused by the need to resolve unique names for programming entities in many modern programming languages.
It provides means to e ...
* Naming collision
Notes
References
Programming language design
Information theory
{{prog-lang-stub