What are com.blah or org.blah?

Discussion in 'Java' started by yaru22, Jan 4, 2007.

  1. yaru22

    yaru22 Guest

    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?
     
    yaru22, Jan 4, 2007
    #1
    1. Advertising

  2. yaru22

    Daniel Dyer Guest

    On Thu, 04 Jan 2007 15:39:04 -0000, yaru22 <> wrote:

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

    --
    Daniel Dyer
    http://www.uncommons.org
     
    Daniel Dyer, Jan 4, 2007
    #2
    1. Advertising

  3. yaru22

    Juha Laiho Guest

    "yaru22" <> said:
    >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?


    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

    --
    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)
     
    Juha Laiho, Jan 4, 2007
    #3
  4. Daniel Dyer wrote:
    > On Thu, 04 Jan 2007 15:39:04 -0000, yaru22 <> wrote:
    >
    >> 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.


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

    :)
     
    John Ersatznom, Jan 4, 2007
    #4
  5. yaru22

    Daniel Pitts Guest

    John Ersatznom wrote:
    > Daniel Dyer wrote:
    > > On Thu, 04 Jan 2007 15:39:04 -0000, yaru22 <> wrote:
    > >
    > >> 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.

    >
    > 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.
     
    Daniel Pitts, Jan 4, 2007
    #5
  6. yaru22

    Daniel Dyer Guest

    On Thu, 04 Jan 2007 18:01:05 -0000, Daniel Pitts
    <> wrote:

    >
    > John Ersatznom wrote:
    >>
    >> 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 :)
    >


    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.


    --
    Daniel Dyer
    https://watchmaker.dev.java.net - Evolutionary Algorithm Framework for Java
     
    Daniel Dyer, Jan 4, 2007
    #6
  7. Daniel Dyer wrote:

    > ...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.
     
    Andrew Thompson, Jan 4, 2007
    #7
  8. yaru22

    Ian Wilson Guest

    Andrew Thompson wrote:
    > Daniel Dyer wrote:
    >
    >
    >>...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 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 :)
     
    Ian Wilson, Jan 5, 2007
    #8
  9. Ian Wilson wrote:
    > Andrew Thompson wrote:

    ...
    > > 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.
     
    Andrew Thompson, Jan 5, 2007
    #9
  10. yaru22

    Berlin Brown Guest

    yaru22 wrote:
    > 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?


    Doesnt matter, next question;

    Berlin Brown
    http://www.botspiritcompany.com/botlist
     
    Berlin Brown, Jan 6, 2007
    #10
  11. yaru22

    Karl Uppiano Guest

    "Ian Wilson" <> wrote in message
    news:...
    > Andrew Thompson wrote:
    >> Daniel Dyer wrote:
    >>
    >>
    >>>...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 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.
     
    Karl Uppiano, Jan 6, 2007
    #11
  12. Karl Uppiano wrote:
    > "Ian Wilson" <> wrote in message
    > news:...
    > > Andrew Thompson wrote:
    > >> Daniel Dyer wrote:
    > >>
    > >>
    > >>>...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 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.


    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.
     
    Furious George, Jan 6, 2007
    #12
  13. Daniel Pitts wrote:
    > 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
     
    John Ersatznom, Jan 6, 2007
    #13
  14. yaru22

    Chris Uppal Guest

    Furious George wrote:

    > 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
     
    Chris Uppal, Jan 6, 2007
    #14
  15. yaru22

    Chris Uppal Guest

    John Ersatznom wrote:

    > Daniel Pitts wrote:
    > > 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
     
    Chris Uppal, Jan 6, 2007
    #15
  16. Chris Uppal wrote:
    > Furious George wrote:
    >
    >> 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
    >
    >
    >


    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!!!
     
    Laurent D.A.M. MENTEN, Jan 6, 2007
    #16
  17. yaru22

    Lew Guest

    Chris Uppal wrote:
    > 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
     
    Lew, Jan 6, 2007
    #17
  18. Laurent D.A.M. MENTEN wrote:
    > Chris Uppal wrote:
    > > Furious George wrote:
    > >
    > >> 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, Jan 6, 2007
    #18
  19. Furious George wrote:
    > Laurent D.A.M. MENTEN wrote:
    > > Chris Uppal wrote:
    > > > Furious George wrote:
    > > >
    > > >> 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.


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

    > >
    > > 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, Jan 7, 2007
    #19
  20. yaru22

    Daniel Pitts Guest

    John Ersatznom wrote:
    > Daniel Pitts wrote:
    > > 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


    Actually, Domain names used to be "free" if you hosted your own DNS
    servers, and Diamonds are a very non-scarce, but quite expensive.
     
    Daniel Pitts, Jan 7, 2007
    #20
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. evolve
    Replies:
    2
    Views:
    509
    William Ryan
    Nov 2, 2003
  2. A. Kong
    Replies:
    2
    Views:
    4,832
    Iwo Mergler
    Oct 11, 2004
  3. Hylander
    Replies:
    0
    Views:
    425
    Hylander
    Jan 16, 2004
  4. Waldy
    Replies:
    1
    Views:
    655
    Alvin Bruney [MVP]
    Oct 21, 2007
  5. mark4asp
    Replies:
    2
    Views:
    365
    George Ter-Saakov
    Jan 8, 2008
Loading...

Share This Page