View Full Version : Package names and folder structure.

03-29-2010, 01:34 PM
There seems to be a convention regarding package names that i can't find information about.

Why does most code have packages (and folders) that start with 'com'. I can't seem to work out where its coming from.


So what's the convention used when naming packages and why?

Any help much appreciated.

Edit: Is this anything to do with class paths, does it make them easier manage? I've got a feeling the answer is really obvious and I'm being dumb, but please just hit me with it.

03-29-2010, 03:01 PM
usually I name my packages com.tenoz.[category] because my company website is 10oz.com You will notice others do the same thing.
com.greensock.TweenLite is from greensock.com
org.papervision3d.[whatever] from papervision3d.org

It's a good way to ensure that your package name is somewhat unique in the community of developers. Then the sub package names [core, display, data, utils, etc...] are just a way to keep things organized to help you and others find what they need.

03-29-2010, 03:30 PM
following naming convention is a way to avoid naming conflict but personally I do not use that. I actually dislike having all these com folders which obviously is a pain when you want to have two of them in the same folder. So to avoid this problem you need to use them as SWC but what if you don't want too like me? Then it's just a pain ...

using packages is a way to organize your code/class. It also allows you to keep some classes from being directly used (internal).

03-29-2010, 04:56 PM
Sure, package can be a little bothersome sometimes and I often use SWCs when available. But, if you've ever worked with other developers on a project or had to make some updates to someone else's project, I think you will be thankful for an organized package structure.

Have a custom button? That class can be found in com.tenoz.display
Need to make a change to the XMLParser class? You will find it in com.tenoz.utils

Also, it's always nice to have my code clearly separate from the libraries that I found online.

By the way, I really like the new Flash Builder 4's SWC explorer. It's so nice to be able to see what public methods and properties I have access to without having to constantly check the PV3D documentation online.

03-30-2010, 07:36 AM
Ohhhhh, thought it would be obvious, like a domain name backwards right?

Ok so what would be the convention if you are writing applications or games for deployment on other websites.

I can see how using this convention would help, my problem is at the moment i find that i sometimes more where classes are located. Then have to go through and change all the package names and the import names. Is there any way to automate that in CS4 or even apps like FlashDevelop?

Thanks for the help.

03-30-2010, 02:32 PM
In Flash Builder 4 or Flex 3 or even Flash Develop there is a key command that will automatically update your imports (adding or removing anything that it needs to). Something like ctrl+shift+O... I don't remember because I never use it (since it automatically updates the imports as I type my code).

Since I am always developing for other companies with their own websites I just keep using my own company's domain for the package name. They usually don't care since no one should ever see the code anyways. This way I can re-use classes without having to change the package structure every time.

I know my boss though always uses the client's domain for his package names... but he never changed them. We end up having tons of packages in each project with a different names and none of it making sense to anyone but us because we know the code well enough.