Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I've noticed that a lot of companies use "reverse domain name" namespaces and I'm curious where that practice originated and why it continues. Does it merely continue because of rote practice, or is there an outstanding architecture concept I might be missing here?

Also note questions such as: http://stackoverflow.com/questions/189209/do-you-really-use-your-reverse-domain-for-package-naming-in-java that sort of answer my question but not 100%

(If it makes you feel any better, I'm really curious if I should be using it for my javascript namespacing efforts, but I'm more curious about then when and why, and that should help guide me on the javascript answer, nota bene: "window")

Example of this practice extending to folders and files: http://imgur.com/jtdXo

share|improve this question
1  
This is strange, I have never seen this before.. now I'm curious. –  Jimmy Hoffa Dec 21 '12 at 21:47

3 Answers 3

up vote 45 down vote accepted

Reverse Domain Notation has it's origins in Java, but is widely used in many platforms, such as Android Packages, Mac OS X Packages, JavaScript, ActionScript, and more.

The practice is extremely useful because it provides a decentralized system for namespacing software. There is no need to apply to a centralized agency for a namespace; simply use the domain name you own (reversed) and manage that within your own organization. By naming packages like this, one can be almost certain that code won't conflict with other packages.

From Oracle's Java Tutorials:

Companies use their reversed Internet domain name to begin their package names for example, com.example.mypackage for a package named mypackage created by a programmer at example.com.

Name collisions that occur within a single company need to be handled by convention within that company, perhaps by including the region or the project name after the company name (for example, com.example.region.mypackage).

It's more than a rote practice, it's good practice because it's a complete and fully specific namespace. If there were two companies named Acme and both chose the namespace acme., their code would conflict. But only one of those companies can own the domain acme.com, so they get to use the com.acme. namespace.

Reversing the domain name allows for a top-down architecture. com would contain code for companies (or anyone who owns own a .com domain name), and underneath that would company (domain) names. Then, deeper within that would be the structure of the organization and/or the actual namespace. (For example, if it was code from a network called internal.acme.com, that gives this department their own sub-namespace of com.acme). This top-down structure is used in a number of applications, including in systems administration. (It's similar to reverse IP address lookups)

Personally, I use it for all new JavaScript code I write for my company. It ensures that the code will never conflict with any other code, even if I later write the same code for another company. It can make accessing the code cumbersome (typing com.digitalfruition. can get a bit much) but that can easily be worked around witha closure and a local variable. (var DF = com.digitalfruition)

share|improve this answer
    
I should be thinking of changing the random package name of my Android app... or buy that domain. :( –  jadkik94 Dec 28 '12 at 11:22

It's because using namespaces reduces the chances of name conflicts tremendously, and because using your domain name (which has already been regulated) is a good way to create a global namespace.

By reversing the domain part in the namespace, you make it sortable; all names that belong to your little chunk of the namespace universe are sorted together.

And last but not least, the TLD .com is the most popular TLD on the internet, so it's used by more software developers than any other TLD.

In any case, the practice started with Java, where each and every class needs to have it's own file, and to play in a larger ecosystem the global namespace scheme was introduced to help keep classes easy to qualify.

share|improve this answer

Endianness

I'm not a java expert, but as to the general pattern this is just another permutation of big-endian vs little-endian, metaphorically speaking.

"Endianness" is sometimes used to describe the order of the components of a domain name, e.g. 'en.wikipedia.org' (the usual modern 'little-endian' form) versus the reverse-DNS 'org.wikipedia.en' ('big-endian', used for naming components, packages, or types in computer systems, for example Java packages, Macintosh ".plist" files, etc.). URLs can be considered 'big-endian', even though the host part could be a 'little-endian' DNS name.

In this case, its presumably for organizational purposes to allow for natural grouping / tree branching. It keeps things tidy at a higher level, and you dig down for more specific detail.

The alternative would be very flat, and meaningful / potentially useful grouping would have to be interpreted vs being intrinsic to the structure.

share|improve this answer
6  
Golly, never heard endianness used to refer to the reverse-domain namespace scheme.. –  Martijn Pieters Dec 21 '12 at 21:52
    
I hadn't either, until a colleague threw it out in a conversation and spawned some tangential discussion. He ref'd wikipedia (as linked to), so apparently it isn't unheard of. I had to relax my literal mind a bit to accommodate this point of view, but I can live with it. –  Ed Hastings Dec 21 '12 at 22:02
    
Yeah, I can see how it could have come about, just hadn't come across the usage before. It's not the most common term for the scheme, I'd wager. –  Martijn Pieters Dec 21 '12 at 22:03
3  
Yeah, this discussion of DNS endianness comes around periodically. The now-long-gone "Janus" network in the UK had its names the other-way-round, and they always said the ARPANet crowd got things backwards. –  Ross Patterson Dec 21 '12 at 22:16
3  
@RossPatterson: Filesystems, Operating Systems, Faceted Classification Systems, Library Filing Systems, phone numbers, most of them start with the root at the left and then get more specific. Heck, even most DNS name server configuration files do it that way. So, I'd agree with the Janus crowd. –  Jörg W Mittag Dec 22 '12 at 3:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.