Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2007

Tip: Looking for answers? Try searching our database.

What are com.blah or org.blah?

Thread view: 
yaru22 - 04 Jan 2007 15:39 GMT
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?
Daniel Dyer - 04 Jan 2007 15:45 GMT
> Whenever I look at an open source code, I see people write com or org
> in their import section.
[quoted text clipped - 3 lines]
>
> 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.

Signature

Daniel Dyer
http://www.uncommons.org

John Ersatznom - 04 Jan 2007 17:29 GMT
>> Whenever I look at an open source code, I see people write com or org
>> in their import section.
[quoted text clipped - 10 lines]
> 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 ...

:)
Daniel Pitts - 04 Jan 2007 18:01 GMT
> >> Whenever I look at an open source code, I see people write com or org
> >> in their import section.
[quoted text clipped - 31 lines]
>
> :)

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.
Daniel Dyer - 04 Jan 2007 20:26 GMT
>> Has anyone come up with any good alternatives for Java developers
>> without any domain names to call home? I've seen a few use
[quoted text clipped - 11 lines]
> 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.

Signature

Daniel Dyer
https://watchmaker.dev.java.net - Evolutionary Algorithm Framework for Java

Andrew Thompson - 04 Jan 2007 20:50 GMT
> ...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.
Ian Wilson - 05 Jan 2007 16:55 GMT
>>...you can probably come up with package names
>>along similar lines.  If you host your project on java.net or
[quoted text clipped - 9 lines]
>
> 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 :-)
Andrew Thompson - 05 Jan 2007 17:29 GMT
..
> > And if all else fails, perhaps 'ind' for 'individual'..
> >
> >   ind.thompson.andrew.MyClass
..
> 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.
Karl Uppiano - 06 Jan 2007 06:33 GMT
>>>...you can probably come up with package names
>>>along similar lines.  If you host your project on java.net or
[quoted text clipped - 12 lines]
> 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.
Furious George - 06 Jan 2007 07:35 GMT
> >>>...you can probably come up with package names
> >>>along similar lines.  If you host your project on java.net or
[quoted text clipped - 16 lines]
> 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.
Chris Uppal - 06 Jan 2007 15:43 GMT
> 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
Laurent D.A.M. MENTEN - 06 Jan 2007 16:35 GMT
>> 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
[quoted text clipped - 4 lines]
>
>     -- 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!!!
Furious George - 06 Jan 2007 23:44 GMT
> >> 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...).

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.

> >     -- 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!!!

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.
Furious George - 07 Jan 2007 00:16 GMT
> > >> 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
[quoted text clipped - 5 lines]
> 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.

> > >     -- chris
> >
[quoted text clipped - 4 lines]
> email me both numbers so I will not mistakenly use them in my java
> projects.
Chris Uppal - 07 Jan 2007 14:51 GMT
> 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.

Nice ;-)

   -- chris
John Ersatznom - 06 Jan 2007 09:14 GMT
> 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
Chris Uppal - 06 Jan 2007 15:49 GMT
> > 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?

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
Lew - 06 Jan 2007 17:16 GMT
> 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
[quoted text clipped - 4 lines]
> 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
John Ersatznom - 08 Jan 2007 07:52 GMT
> 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
[quoted text clipped - 4 lines]
> somewhere with an associated global URL -- in which case you can use that for
> the root of the package names.

Then you get into the problem of ensuring that that URL continues to
belong to your software for as long as the software remains in use. It's
very hard to get any kind of stable Web hosting at all on a budget
nowadays ("stable" as in "url doesn't change -- ever"). Probably you
also want the javadocs to be hosted stably for others to link to.

Why isn't there a good, free Web host these days, let alone one with
staying power that doesn't rearrange things internally on its own? It
seems you're artificially constrained to three options -- keep your
software entirely private, use an existing open source hosting site like
SourceForge, or go commercial *and be successful*. Anything else means
paying for hosting out of your own pocket, *on top* of whatever you
already pay for network access (shouldn't hosting of at least a small to
medium amount of data at a stable address be included as basic network
access? But it's not...) and that means you'll be paying to keep your
Java online and legitimate for a lifetime (its or yours).

So much for "free", even as in beer...
Daniel Pitts - 07 Jan 2007 03:40 GMT
> > 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
[quoted text clipped - 23 lines]
> 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.
Tor Iver Wilhelmsen - 07 Jan 2007 11:27 GMT
> Has anyone come up with any good alternatives for Java developers
> without any domain names to call home?

Just use whatever you deem unique for you. The use of the domain name
is a convention, not enforced in any way, but is the package naming
convention least likely to generate collisions when someone else uses
the classes. For code that lives just in your system, use whatever you
want.

Counterexample: Microsoft early on used the package structure
"com.ms.*" even though they didn't have the "ms.com" domain;
presumably "ms" was easier to type for lazy Redmond programmers than
"microsoft". :P
Chris Uppal - 07 Jan 2007 15:11 GMT
> Counterexample: Microsoft early on used the package structure
> "com.ms.*" even though they didn't have the "ms.com" domain;

And ms.com was a real domain at the time too -- for yet another dose of
corporate arrogance.  I seem to recall that it was owned by some law firm at
the time (a very vague memory), although it's owned by Morgan Stanley now.

I agree, though, that the package naming convention is better viewed as a very
sensible guideline, than as a Rule Which Must Never Be Broken.

   -- chris
John Ersatznom - 08 Jan 2007 07:54 GMT
>>Counterexample: Microsoft early on used the package structure
>>"com.ms.*" even though they didn't have the "ms.com" domain;
[quoted text clipped - 5 lines]
> I agree, though, that the package naming convention is better viewed as a very
> sensible guideline, than as a Rule Which Must Never Be Broken.

Agreed. In fact, given the choice between paying an additional $35 a
month for life to "rent" my package name root or breaking the
convention, I'll pick breaking the convention -- especially on my
current income, which is not particularly stellar (under $20K/year USD)...
Daniel Dyer - 08 Jan 2007 09:34 GMT
> Agreed. In fact, given the choice between paying an additional $35 a  
> month for life to "rent" my package name root or breaking the  
> convention, I'll pick breaking the convention -- especially on my  
> current income, which is not particularly stellar (under $20K/year  
> USD)...

A fair point but, just to be clear, it's not per month - $35 will get you  
2 years.

Dan.

Signature

Daniel Dyer
http://www.uncommons.org

Juha Laiho - 04 Jan 2007 15:57 GMT
"yaru22" <yaru22@gmail.com> said:
>Whenever I look at an open source code, I see people write com or org
>in their import section.
[quoted text clipped - 3 lines]
>
>What do they stand for? Is it a conventional thing?

They're packages; please see the Java Tutorial at Sun:
http://java.sun.com/docs/books/tutorial/java/package/packages.html
and
http://java.sun.com/docs/books/tutorial/java/package/namingpkgs.html

Signature

Wolf  a.k.a.  Juha Laiho     Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
        PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)

Berlin  Brown - 06 Jan 2007 00:11 GMT
> Whenever I look at an open source code, I see people write com or org
> in their import section.
[quoted text clipped - 3 lines]
>
> What do they stand for? Is it a conventional thing?

Doesnt matter, next question;

Berlin Brown
http://www.botspiritcompany.com/botlist


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.