So most Java resources when speaking of packages mention a com.yourcompany.project
setup. However, I do not work for a company, and don't have a website. Are there any naming conventions that are common? An email address, perhaps?
views:
494answers:
11Use a top-level domain like 'bernard' or something else unique. The important part is that the domain is unique so that you avoid clashes, and not that it starts with a real Internet top-level domain like org or com. E.g.
import java.util.*;
import bernard.myProject.*;
import org.apache.commons.lang.*;
Good advice on this topic found on the web: "Start your package names with your email address, reversed.[...] Or, host your code at a site which will give you a slice of their domain."
Why not register a domain?
They're fairly cheap and doing so will guarantee that you don't clash with anybody else (Or at least give you the satisfaction that if a clash does occur, it's the other person who will have to rewrite their code)
Either register your own name, or try to make up a name that you may use as the basis for a business at a later date.
bernard.surname.net ...or... madeupname.net
Either will cost you less than 10GBP per year.
Personally, I'd go for the made up name approach, as it's likely to look more professional (Unless you choose something really strange).
An added advantage is that a lot of domains will come with email capabilities, giving you a better email address than [email protected].
What you can do also is register a domain (actually a sub-domain) through a service such as DynDns (or one of the equivalents) and then use that domain name. You will be the sole controller and it is free and easy to maintain. They have a choice of 88 top domains at the moment (October 2008). dyndns dynamic dns service
If your creating an open source project, you could register it with Sourceforge and use net.sourceforge.myproject. This is common with a lot of Java projects. An example is PMD http://pmd.sourceforge.net/.
For my own personal work when I don't have a namespace, I go for something simple like org.<myname>.*
I've been in a couple different companies who write house java classes. Often they're just com.blah.blah.blah
without regard to whether there's a actual domain name behind it.
IMHO, best if it does not depend on any external information, such as hosting provider or company (it could be released to the open source community), since package-level refactoring is not quite desirable, especially in the case of frameworks and libraries. I suggest choosing your project name carefully and unambiguously, then using org.<project name> as the root package.
Note that the "reverse domain name" thing is just a convention: useful since it definitely avoids clashes if everyone adhers to it, but you don't have to follow it.
Just choose a name that you can be reasonably sure nobody else will use and which is not registered as trademark by anyone - because that's the one way you could actually get into legal trouble.
And that means it's in fact a rather bad idea to use some sort of "subdomain" of a free service you're using, like deviantart or a dyndns or free mail service! Because most (if not all) of those domains are trademarked terms, and if your projects ever gets widely distributed, it could be seen as violating the trademark. Just because they allow you to use that name as an email address (or whatever) doesn't mean you can use it for anything else - in fact, their EULA almost certainly restricts usage to exactly that one purpose.
Many people have their own websites and relatively unique names (or login names).
If your name is Bernard Something, you may own BernardSomething.com, making com.bernardsomething.xxxx (or com.bsomething.xxx) a legitimate package name IMHO for personal code.
That being said, If your project name is unique, you may want to name the package after that.
And of course, get the domain after your name if you don't own it yet!