Package naming conventions

Hi Everyone,

When I did work on android based Apps, it was very important that your package names were unique
so I proceeded to use the normal naming conventions org.something.main etc.

I was wondering is this true for Java games that get deployed to be used on the desktop, should your Classes be put in uniquely identified packages? (com.gameengine.utils)

As a side note: What would you use if you don’t have a website or even a game title to use yet, in creating package names.

Thanks

just use your name or nickname as toplevel package. then use subpackages to group things you want to group like you are usually using folders. you may also put the projects (code-)name in the middle,if you want… as long as you don’t want to release your code as library, dont bother too much about packages. just dont put any classes or stuff in the default package (toplevel without folders), and you’ll be fine. even this advice is actually just common convention and might only be relevant if you use classpath scanners or get deployed in a shared environment with classloader hierarchies…

It’s often your home/company webpage - in reverse, for example “org.java-gaming” - there are several sites to make free websites, for example www.devhub.com

http://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html

its only important if you write a 3rd party API to be used by others or develop on android

other than that I never do it, its kinda silly

I’ve got my own domain name so that part isn’t an issue, but I’m still not sure what path to take with prototypes. Typically I’ll just give it a name that vaguely describes what I think the game will be, but often the nature of (or story behind) the game changes so much that the name no longer fits. I then need to do some refactoring to change the package name. It’s not a big deal, but has the potential to play havoc with your version control, in particular comparing older versions of files when their folder has changed.

Does anybody use code names for their packages when in the prototype phase? Or even sequential names, eg. game102?

I first use [icode]com[/icode]. Then I add the project name such as my GEJ in lower caps. It becomes [icode]com.gej[/icode]. Then I’ll start grouping the classes into multiple packages, like [icode]com.gej.core[/icode] and all. I’ll never keep a class in the root i.e., [icode]com.gej[/icode]. If there’re anyone, I’ll move them to the [icode]core[/icode] sub package.

Thanks you all, all of this is very helpful, I went with the com.[PROJECT_NAME].[MODULE],
this seems the best way to logically group everything.

In the Java docs they also talk about package-private which then fits in nicely, even though
I would never declare class and class members without a access specifier.
http://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html

It’s often your home/company webpage - in reverse, for example “org.java-gaming” - there are several sites to make free websites, for example www.devhub.com

http://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html

its only important if you write a 3rd party API to be used by others or develop on android

other than that I never do it, its kinda silly

I’ve got my own domain name so that part isn’t an issue, but I’m still not sure what path to take with prototypes. Typically I’ll just give it a name that vaguely describes what I think the game will be, but often the nature of (or story behind) the game changes so much that the name no longer fits. I then need to do some refactoring to change the package name. It’s not a big deal, but has the potential to play havoc with your version control, in particular comparing older versions of files when their folder has changed.

Does anybody use code names for their packages when in the prototype phase? Or even sequential names, eg. game102?

I first use [icode]com[/icode]. Then I add the project name such as my GEJ in lower caps. It becomes [icode]com.gej[/icode]. Then I’ll start grouping the classes into multiple packages, like [icode]com.gej.core[/icode] and all. I’ll never keep a class in the root i.e., [icode]com.gej[/icode]. If there’re anyone, I’ll move them to the [icode]core[/icode] sub package.

Thanks you all, all of this is very helpful, I went with the com.[PROJECT_NAME].[MODULE],
this seems the best way to logically group everything.

In the Java docs they also talk about package-private which then fits in nicely, even though
I would never declare class and class members without a access specifier.
http://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html