tags:

views:

157

answers:

8

I've read the syntax conventions for naming Java packages, and I know the general rule of thumb, but what if you've just started building your application, you haven't chosen a license, and it is a personal project? It doesn't make sense to throw in "com.mycompany" or "org.myorganization" if that is not the case. Does anyone have suggestions for this?

+1  A: 

Perhaps org.{myname} ?

I don't think it particularly matters for personal projects. In fact I've seen commercial (in-house) projects flout this rule and simply call their packages {servicename} or similar (which I don't particularly like). The packaging rules are designed to prevent name clahes when sharing code cross-enterprise (or organisation) and consequently for personal projects you can use most anything.

Brian Agnew
+1  A: 

Java packages are just for namespacing. Call it whatever you want! Think of something that will be useful to you later on when you want to remember what this code was supposed to do.

danben
A: 

I generally use nl.myname.myapp for all personal projects. There is no rule against open sourcing something that uses your personal name. If you decide to make the project bigger and create a web site for it you can always rename the packages if you really want to.

Gerco Dries
+1  A: 

how about org.{projectname}? Think about some open-source projects (e.g. org.hibernate, org.springframework and org.junit) ... did they start this way because it was the name of the website, or the name of the project itself?

Besides, re-factoring is so trivial these days, just name it whatever you want.

Yoni
Hibernate was packaged as `net.sf.hibernate` initially.
Pascal Thivent
And JUnit was using (and still uses) `junit.framework` btw :)
Pascal Thivent
@Pascal, right, that's a fair point, but still I think that my suggestion for org.projectname is valid.
Yoni
My comments are more related to the second part of your answer. Now, regarding your suggestion, it is indeed valid for private code. But if the code goes public, you should use a domain you own (but this is a personal point of view and another story).
Pascal Thivent
+4  A: 

Many Java books and online examples just use the name of the book or project, i.e., ejb3inaction.* or tutorial.*.

Kaleb Brasee
A: 

What about name.yourname.myproject or net.sf.myproject or com.googlecode.myproject or simply myproject.

As long as you don't make your code public, it's not that important actually (and you can easily refactor it later before releasing your code if you need to). Once people start using your code, it's another story...

Pascal Thivent
+1  A: 

In the case you might also think about sharing the project (making it an open-source project), to open an project entry, in that case you can use something like 'net.sf.{project-name}.*', be careful here, that the project-name, must be the unix name, of the project (at least then you follow the rules correctly :)

Verhagen
See also this related question http://stackoverflow.com/questions/10490/best-open-source-project-hosting-site to make the selection.
Verhagen
A: 

I usually just go with something like lastname.firstname.<other packages>. The package name should just be unique, and the combination of your last name and first name is probably unique enough (if you have a common name, throw in a middle initial or a middle name or something like that).

mipadi