views:

86

answers:

6

"TLD-first domain-like identifiers" is a mouthful but that's all I can come up with.

I've seen these used in various places over the years and wondered what the history/reason behind this convention is, since you might be forgiven in thinking that there is one true way to mention a domain.

I don't use Java but I recall from poking around that namespaces are often done like this:

uk.co.tophats.stitchkit

A specification file for a "Launch Agent" on Mac OS X:

ws.agile.1PasswordAgent.plist

A preferences file on Mac OS X:

com.apple.iTunesHelper.plist

Why is the TLD first? Is it just hierarchical pedantry like UK vs. US date formats?

+1  A: 

It's a bit subjective. You can be used to conventions like "stackoverflow.com", and wonder what the heck all this "com.apple" stuff is about. Or you can be a programmer with years of experience and stuff like "System.out" could be the most natural thing for you.

com.apple is like saying "look into the com domain, inside this, look for apple".

apple.com is like saying "look for apple, which can be found in the com domain".

So it all depends on the environment/situation you're using. Just my two cents!

Michael
+3  A: 

For the case of Java, the packages correspond directly to directory hierarchy, and it makes far more sense for the directory hierarchy to be rooted at the most general, rather than the most specific, domain identifier. Also, when reading off directory hierarchy, it is most common to read it from the top down. So I'd say the convention of flipping the order of domain components makes sense there.

Owen S.
+1 for this: "... it makes far more sense for the directory hierarchy to be rooted at the most general, rather than the most specific ..."
jensgram
+1  A: 

Its a way of using a globally unique name as the prefix to all your namespaces and thus keep all your namespaces private to the globally unique name.

Preet Sangha
+1  A: 

In Java and other programming languages, the package identifier dictates how the directory hierarchy of the project is.

So if you have two packages com.stackoverflow.server and com.stackoverflow.client, you'll end up with this directory layout:

com/
   stackoverflow/
      client/
      server/

which is good and logical, while the other way around would give you

client/
   stackoverflow/
      com/
server/
   stackoverflow/
      com/

which is impratical.

rjack
This applies to .class files, not to the sources. You can have your source organized as com/stackoverflow/client but write client.stackoverflow.com as package. Most IDE's will complain but compile anyway ... No good practice, but good to know.
PeterMmm
+1, didn't know that
rjack
A: 

No, it's not pedantry, it's to create a namespace.

There might be other 3 party developers/programs/etc. that also could create a iTunesHelper.plist or a SQLRunner.java class. You prefix these with your own namespace, e.g. your domain name to create a reasonably unique name so com.oracle.SQLRunner.java is different and doesn't clash with org.postgresql.SQLRunner.java

nos
I know the benefit of namespaces, it's the order of the units (e.g. com comes first) that was in question :-)
frou
It's a practical convention to place the most significant units to the left. we do that in e.g. phone numbers, numeral systems, filesystem hierarchies, most taxonomy system goes from left to right (Though DNS does not.)
nos
+1  A: 

In sience, notation is normally started with the most significant bit of information, to make ordering and grouping of the information easier. The TLD is the root of the domain structure and thus the most significant bit of information. So it makes sense to structure the packages this way. Sure, it doesn't matter if it's com.example.mypackage or example.com.mypackage. But SUN decided to prefer the more sientific way.

Regarding the date format, be aware that there is an ISO describing an "interchange format" as: YYYY-MM-DD
It's the same scheme, because the year is the most significant part, followed by the Month and Date.

So, when looking from this point, the one who is using the "wrong" notation is the DNS system itself. But I think they tried to optimize the whole thing for parsing of an url (e.g. The "www" first, to indicate a WebServer)

Hardcoded