Naming collision
From Wikipedia, the free encyclopedia
A naming collision is a circumstance where two or more identifiers in a given namespace or a given scope cannot be unambiguously resolved, and such unambiguous resolution is a requirement of the underlying system.
Contents |
[edit] Example: XML element names
In XML, element names can be originated and changed to reflect the type of information contained in the document. This level of flexibility may cause problems if separate documents encode different kinds of information, but use the same identifiers for the element names.
For example, the following sample document defines the basic semantics for a both "person" document and a "book" document. Both of these use a "title" element, but the meaning is not the same:
<root> <person> <fname>Nancy</fname> <lname>Davolio</lname> <title>Dr.</title> <age>29</age> </person> <book> <title>Ms.</title> <isbn>ABCD1234567</isbn> </book> </root>
For an application to allow a user to correctly query for and retrieve the "title" element, it must provide a way to unambiguously specify which title element is being requested. Failure to do so would give rise to a naming collision on the title element (as well as any other elements that shared this unintented similarity).
In the preceding example, there is enough information in the structure of the document itself (which is specified by the "root" element) to provide a means of unambiguously resolving element names.
For example, using XPath:
//root/person/title ;; the formal title for a person //root/book/title ;; the title of a book
[edit] Collision domain
This article or section may contain original research or unverified claims. Please improve the article by adding references. See the talk page for details. (September 2007) |
The term collision domain may also be used to refer to a system in which a single name or identifier is open to multiple interpretations by different layers or processing. The notion of a namespace has been widely adopted as a software programming practice to avert undesired clashes.
The analogy to ethernet collision domains is rather direct. In many cases, a small software system that begins life with little concern for namespace semantics later grows to become a large software system with undesirable and problematic collision domains (concerning names used within the system) that a mature architectural approach would have eliminated in the design phase. It is no longer considered acceptable practice to design a system without considering namespace semantics. The C preprocessor is a good example of a language facility that remains pervasive, which is no longer accepted as good practice. [1] The same evolution has taken place from the older generation of broadcast ethernet hubs which functioned as collision domains, but have now been replaced by superior switched devices.
Conceptually, however, the metaphor is indirect because broadcast ethernet involves collisions in time concerning a shared resource (the transmission line), rather than collisions in the naming of objects or services.
[edit] See also
[edit] References
- ^ Bjarne Stroustrup complains about this bitterly in The Design and Evolution of C++.