What are com.blah or org.blah?

Y

yaru22

Whenever I look at an open source code, I see people write com or org
in their import section.

i.e. import com.blah.blah
import org.blah.blah

What do they stand for? Is it a conventional thing?
 
D

Daniel Dyer

Whenever I look at an open source code, I see people write com or org
in their import section.

i.e. import com.blah.blah
import org.blah.blah

What do they stand for? Is it a conventional thing?

The convention is to base your package names on your domain name. The
idea is to avoid naming collisions. For example, nobody but me should
write a class in the org.uncommons.* namespace, so there should never be
another class with the same fully-qualified name as mine. This means my
classes should be able to mix classes from other libraries without the
possibility for naming problems.

Dan.
 
J

John Ersatznom

Daniel said:
The convention is to base your package names on your domain name. The
idea is to avoid naming collisions. For example, nobody but me should
write a class in the org.uncommons.* namespace, so there should never
be another class with the same fully-qualified name as mine. This
means my classes should be able to mix classes from other libraries
without the possibility for naming problems.

Unfortunately, whoever cooked up this convention was obviously somewhere
corporate, where everyone and his brother makes $70,000+/year and they
can all afford to own their own domain names. Apparently in the utopian
workers paradise where noone ever gets laid off and has to let their
$whatever/month business-class Web hosting lapse or face starvation, at
that. And, of course, didn't bother to think up a convention for the
rest of us (tm), us joes who have a consumer broadband account and some
page on Yahoo or Myspace or even, if we're lucky, at www.ourisp.com. But
do we really want to be making huge numbers of com.myspace.MyClass
classes? Somehow I think that defeats the purpose. :)

Has anyone come up with any good alternatives for Java developers
without any domain names to call home? I've seen a few use
org.sourceforge.<projectname>.subpackages-if-any.Foo when they have an
actual sourceforge project, but that's also not exactly
universally-applicable...

I suppose you could use com.myspace.<username-at-myspace>.Foo ...

:)
 
D

Daniel Pitts

John said:
Unfortunately, whoever cooked up this convention was obviously somewhere
corporate, where everyone and his brother makes $70,000+/year and they
can all afford to own their own domain names. Apparently in the utopian
workers paradise where noone ever gets laid off and has to let their
$whatever/month business-class Web hosting lapse or face starvation, at
that. And, of course, didn't bother to think up a convention for the
rest of us (tm), us joes who have a consumer broadband account and some
page on Yahoo or Myspace or even, if we're lucky, at www.ourisp.com. But
do we really want to be making huge numbers of com.myspace.MyClass
classes? Somehow I think that defeats the purpose. :)

Has anyone come up with any good alternatives for Java developers
without any domain names to call home? I've seen a few use
org.sourceforge.<projectname>.subpackages-if-any.Foo when they have an
actual sourceforge project, but that's also not exactly
universally-applicable...

I suppose you could use com.myspace.<username-at-myspace>.Foo ...

:)

You think you're funny don't you? :)

Actually, I'd be amazed if you could afford a java-development computer
and NOT afford a $35/yr domain name. No one said you had to have a
website, just a domain :)

- Daniel.

P.S. I host my own sites :) Not a big deal.
 
D

Daniel Dyer

You think you're funny don't you? :)

Actually, I'd be amazed if you could afford a java-development computer
and NOT afford a $35/yr domain name. No one said you had to have a
website, just a domain :)

Domains are getting cheaper all the time. You can get a .com for £8 ($15
US) or a .co.uk for £2.95 a year.

Even if that is out of reach, you can probably come up with package names
along similar lines. If you host your project on java.net or
sourceforge.net you have a ready-made sub-domain. If you are a student
you can use your university or college's domain combined with your user
account name, e.g. <university.domain>.<department>.<username>.

Dan.
 
A

Andrew Thompson

Daniel said:
...you can probably come up with package names
along similar lines. If you host your project on java.net or
sourceforge.net you have a ready-made sub-domain. If you are a student
you can use your university or college's domain combined with your user
account name, e.g. <university.domain>.<department>.<username>.

And if all else fails, perhaps 'ind' for 'individual'..

ind.thompson.andrew.MyClass

(though that is a stupid name, for a class)

Andrew T.
 
I

Ian Wilson

Andrew said:
Daniel Dyer wrote:




And if all else fails, perhaps 'ind' for 'individual'..

ind.thompson.andrew.MyClass

(though that is a stupid name, for a class)

Andrew T.

I suspect more than one individual Andrew Thompsons exists today and
more might exist in the future. So that doesn't seem like a great scheme.

Registering a domain for the price of a cup of coffee or two seems a
reasonable deal for anyone needing to publish Java classes to the world
at large.

When I first registered a .com domain, nic.ddn.mil let you have them for
free :)
 
A

Andrew Thompson

Ian said:
Andrew Thompson wrote: ... ...
I suspect more than one individual Andrew Thompsons ...

1) A microbiologist from the UK
2) A Canadian parliamentarian who was ordered
to show his presence before the parliament or risk
dismissal (never followed up what became of him)
3) ..many others.

Screw 'em. They ain't Java coders, and any other
Java coder with the same name would be accused
of impersonating me, should they be silly enough
to use that package name (..by me, anyway).

(Though they might add a real, or arbitrary,
middle name, if they really want to go that way..)
...exists today and
more might exist in the future. So that doesn't seem like a great scheme.

Registering a domain for the price of a cup of coffee or two seems a
reasonable deal for anyone needing to publish Java classes to the world
at large.

Domain names can be 'stolen'.. (just as identities can).

Six of one, half a dozen of the other..

Andrew T.
 
K

Karl Uppiano

Ian Wilson said:
I suspect more than one individual Andrew Thompsons exists today and more
might exist in the future. So that doesn't seem like a great scheme.

The amount of effort to make your packages globally unique should be
proportional to the likelihood that they will ever need to be globally
unique.
 
F

Furious George

Karl said:
The amount of effort to make your packages globally unique should be
proportional to the likelihood that they will ever need to be globally
unique.

If you are losing all your hair worrying about this, then why not just
randomly draw a number from 0,2^128. The probability of a collision is
extraordinarily low.
 
J

John Ersatznom

Daniel said:
Actually, I'd be amazed if you could afford a java-development computer
and NOT afford a $35/yr domain name. No one said you had to have a
website, just a domain :)

The latter is a *recurring* cost, however, and what good is a domain
without a website worthy of a separate domain? Oh -- naming your Java
packages. Of course, that amounts to a defacto $35 annual license
renewal fee for using supposedly free development tools, I hope you
realize...

unless of course you say screw it and just use a made up name unlikely
to be duplicated by anyone else.

I hate to contemplate the amount of refactoring that's needed for any
project still in use when the original domain lapses for whatever reason
to keep it in compliance. Even using Eclipse. And remember, software is
ALWAYS still in use long after everyone planned for it to be. That means
after the domain is sunsetted, after anything else is ... etc.

Is the domain namespace really scarce enough to justify not handing
freebies out to everyone in the world, their dog, AND their organization
for that matter? Charging a not-insignificant (and recurring!) fee for a
non-scarce thing like an identifier smacks of capitalism run amok. It
amounts to an online property tax, being levied by private business, on
the online equivalent of land holdings. What ever became of the good ol'
days of fighting violent, bloody wars in miserable weather in the name
of things like "no taxation without representation!"? :p
 
C

Chris Uppal

Furious said:
If you are losing all your hair worrying about this, then why not just
randomly draw a number from 0,2^128. The probability of a collision is
extraordinarily low.

Or use the MAC address of (one of) the network adaptors in your computer (I
realise that not everyone /has/ a computer, but...).

-- chris
 
C

Chris Uppal

John said:
The latter is a *recurring* cost, however, and what good is a domain
without a website worthy of a separate domain?

It makes no difference how you name your packages if they are only used within
your own organisation (living room, whatever). The only constraint is that
you avoid "inbound" clashes (as it were) which you can do by, say, putting all
your stuff under "local" (local.mystuff.whatever) since "local" isn't a TLD and
is unlikely to become one. If, on the other hand, you /do/ want to make your
code more generally available then you almost certainly are going to put it
somewhere with an associated global URL -- in which case you can use that for
the root of the package names.

-- chris
 
L

Laurent D.A.M. MENTEN

Chris said:
Or use the MAC address of (one of) the network adaptors in your computer (I
realise that not everyone /has/ a computer, but...).

-- chris

and why not use your bank account number? this one is unique for sure
and you the least you can even expect is some guy gives you money!!!
 
L

Lew

Chris said:
It makes no difference how you name your packages if they are only used within
your own organisation (living room, whatever). The only constraint is that
you avoid "inbound" clashes (as it were) which you can do by, say, putting all
your stuff under "local" (local.mystuff.whatever) since "local" isn't a TLD and
is unlikely to become one. If, on the other hand, you /do/ want to make your
code more generally available then you almost certainly are going to put it
somewhere with an associated global URL -- in which case you can use that for
the root of the package names.

In fact, the use of non-standard TLDs solves the "people's rights against the
fatcat capitalists!" rave. You only have to pay for domains under ICANN
hegemony, and then only if you intend them to be visible on the 'Net. You are
not forbidden to use, say, 'com.exxon.whatever' for your own package names,
except insofar as you publish them in a way that conflicts with someone's
intellectual property or trademark rights.

But 'folk TLDs' avoid even that problem. You could even use your name itself
as a domain:

doe.john.m.somepackage

or we could as a society agree that 'local' or 'indiv' or some such is the
global free TLD, and just risk collisions. After all, if by some fluke both
John M. Q. Doe, IIIs wrote Java(tm) code, what are the chances that their
package and class names will collide in the same project? If it did in my
project, I'd probably contact both Does to ask their help.

package indiv.doe.john.m.q.iii.somepackage;

- Lew
 
F

Furious George

Yeah, but what if I sell the computer. Then I have to refactor. What
a pain. I think it would be better to use a number based on your DNA.
and why not use your bank account number? this one is unique for sure
and you the least you can even expect is some guy gives you money!!!

To guarantee uniqueness, you should include your PIN. Make sure to
email me both numbers so I will not mistakenly use them in my java
projects.
 
F

Furious George

Furious said:
Yeah, but what if I sell the computer. Then I have to refactor. What
a pain. I think it would be better to use a number based on your DNA.

I've got it. Everyone who owns a MAC address can have a java domain of
the form
mac.${MACADDRESS}.${TIMESTAMP}
where ${MACADDRESS} is their respective MAC address and ${TIMESTAMP} is
the Unix timestamp of some date in which they owned the MAC address.

Advantages:
Most people can have many more domains than they would ever use.
If they sell the MAC address, the new owner will not collide with them.

Disadvantages:
Some people don't own and have never owned a MAC address.
We would have to get ICANN to promise never to release mac as a TLD.
Defective clocks could cause collisions.
 
D

Daniel Pitts

John said:
The latter is a *recurring* cost, however, and what good is a domain
without a website worthy of a separate domain? Oh -- naming your Java
packages. Of course, that amounts to a defacto $35 annual license
renewal fee for using supposedly free development tools, I hope you
realize...

unless of course you say screw it and just use a made up name unlikely
to be duplicated by anyone else.

I hate to contemplate the amount of refactoring that's needed for any
project still in use when the original domain lapses for whatever reason
to keep it in compliance. Even using Eclipse. And remember, software is
ALWAYS still in use long after everyone planned for it to be. That means
after the domain is sunsetted, after anything else is ... etc.

Is the domain namespace really scarce enough to justify not handing
freebies out to everyone in the world, their dog, AND their organization
for that matter? Charging a not-insignificant (and recurring!) fee for a
non-scarce thing like an identifier smacks of capitalism run amok. It
amounts to an online property tax, being levied by private business, on
the online equivalent of land holdings. What ever became of the good ol'
days of fighting violent, bloody wars in miserable weather in the name
of things like "no taxation without representation!"? :p

Actually, Domain names used to be "free" if you hosted your own DNS
servers, and Diamonds are a very non-scarce, but quite expensive.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,434
Messages
2,571,688
Members
48,796
Latest member
Greg L.

Latest Threads

Top