Netscape 8.0: Getting attacked by all sides RE: Why Standardize BeanShell and Groovy?
May 25

Package Naming: To use “com.” or not

Java, Tech Add comments

We were taught to avoid conflicts by using a package name such as com.adigio.subproject.package. This is much better than just using a project name such as “web.” for sure.

However, I keep running into packages such as com.mything.* where mything isn’t a domain at all that the owner owns.

So now, we have moved the namespace clash down a notch.

Do we need the com package anymore? Would adigio.* really be so much worse?

A large part of me thinks not, and as long as we are not stupid and do not pick generic top level packages, we would be fine. This seems to work OK in the other language camps :)

In fact, in some ways, I always liked the fact that: Net::FTP and Net::HTTP could actually be written by different parties…. and that is managed in a different way.

Do you like the com package? (or .net, or .countrycode, etc).

Think about how much package renaming we wouldn’t have to go through in open source (net.sf.* -> org.myproject.*). For example, if Hibernate was just hibernate.* to begin with.

14 Responses to “Package Naming: To use “com.” or not”

  1. Eelco Says:

    We had this discussion for Wicket, and in the end decided to go for wicket.* instead of net.wicket.*, org.wicket.* etc.

    I usually stick with the com.* (or actually nl.* as I make dutch programs mostly) schema, but having used wicket.* for some time, I like the fact that it is short.

  2. Dion Says:

    Eelco -

    Interesting that you made that choice. How are you going to handle the million other wicket.* classes out there though!!! ;)


  3. Eelco Says:

    Uh no, why didn’t we think of that! Glad we haven’t put out 1.0 final yet!

  4. scott Says:

    I keep my proprietary code in the com.domain[...] packages and my open source code in the org.domain[...] packages.

  5. No one Says:

    If people write code for com.mything and they don’t own the domain, they are violating the spec. Domains are cheap. Why should we change the rule because some people violate the spec? If we get rid of the first level and I own and someone else owns, do I have to coordinate my classes with them to make sure we don’t duplicate?

    If I download code and it violates the spec of reverse domain names, it either gets deleted or I refactor it. The bigger the package, the more time it takes to refactor, so it better provide a lot of bang for the buck, or it gets deleted.

    By the way, your comment box is the most annoying comment box anywhere. The cursor doesn’t appear where the text is being typed.

  6. Eelco Says:

    That sounds pretty drastic. Do you refactor because you expect actual conflicts, or because you want to make this world a better place?

    And did you really refactor/delete JUnit, Ognl, Concurrent and Antlr to name of few?

  7. Charles Miller Says:

    Interestingly enough, Hibernate v1 was in the “cirrus.hibernate” package, I suspect because was just way too long already.

    There are also a bunch of Confluence classes in bucket.*, after the paved-with-good-intentions idea that if we put all our common code in there, it’d force us to come up with a good name for the package before we released it. :)

  8. Anonymous Says:

    The conventions will only work if we uphold them.

    When you get into a name confilct with a vendor of yours then you’ll end up renaming packages anyway so there is no gain there.

    That is, if not having your IDE refactor package names for you is a gain in the first place.

    For that matter, i think separating words in class names with _ is nicer, lets try that. Plus no indentation for me. And I also like my comments all at the end of each method.

  9. Eelco Says:

    There is a difference though between accepted standards that leave nothing left for interpretation (like using camel case and starting your methods with javadoc comments) and those that do, like using a domain name. It could be the case that no domain is available. Or you’re not sure whether you will be on the same domain the next year for a starting project. And whether a domain is cheap or not naturally is a relative statement. It might be for you, but not for someone this lives in India or China for example.

  10. Todd Huss Says:

    I stopped preceding package names a few years ago and have yet to run into a problem. Having the package name relate to a domain is silly and serves no practical purpose. If your company is called “Some Java Shop” then I would simply have but use the namespace sjs.*. Preceding with com/net/org also unnecessarily lengthens the namespace forcing you to scroll sooner in your IDE’s package navigator.

  11. SAMUEL Says:

    louisiana home equity loan

  12. SAMUEL Says: health insurance
    health insurance
    [url=]health insurance [/url]

  13. barkas52 Says:

    Barkas52147 Beliy Us

  14. barkas52 Says:

    Barkas52147 Beliy Us

Leave a Reply

Spam is a pain, I am sorry to have to do this to you, but can you answer the question below?

Q: Type in the word 'ajax'