Skip to main content
gamedev.net
🔒 Locked

Java Packages

Started by Monty Python Nov 27, 2003 at 12:37 PM 5 replies 1k views
Original Post
Monty Python
Monty Python
According to the Sun Java code conventions your package names must begin with a top level domain. i.e. com.something.blah. "The first component of a unique package name is always written in all-lowercase ASCII letters and should be one of the top-level domain names, currently com, edu, gov, mil, net, org, or one of the English two-letter codes identifying countries as specified in ISO Standard 3166, 1981." - Quoted from http://java.sun.com/docs/codeconv/html/CodeConventions.doc2.htm. Can anyone explain to me why this is, it seems very strange. Also, does anyone know when Java 1.5 is scheduled for release?
GSACP: GameDev Society Against Crap Posting
To join: Put these lines in your signature and don't post crap!
hplus0603
hplus0603
I can think of two reasons:

1) If you start with a domain that you have registered, then you know that nobody else will use the same name; i e uniqueness is guaranteed.

2) If you want to know where to go for support, updates, etc, then inspecting the name of the package may give you a clue.

I doubt they actually enforce this recommendation, though.
enum Bool { True, False, FileNotFound };
Monty Python
Monty Python
Ah I see, thanks for clearing that up.
GSACP: GameDev Society Against Crap Posting
To join: Put these lines in your signature and don't post crap!
Aldacron
Aldacron
Yes, the primary reason is for uniqueness. You can call your packages anything you want, and it''s not unusual for a top level package name to be that of the application it is coded for. However, if you are writing any kind of code that is intended to be used by other developers in any way, shape, or form, it is a very good idea to follow the Sun conventions. Many Java bashers are quick to blast the accepted conventions as being ridiculous. However, they go a long way to making code readable, easy to understand, easy to maintain, and (in the case of package names) result in fewer namespace collisions.
Monty Python
Monty Python
One more question, if I have a website in the UK i.e. gamedev.co.uk (this is just an example) how would I name the package? Would it be like this:

package uk.gamedev.co.packagename;

or:

package co.uk.gamedev.packagename;

GSACP: GameDev Society Against Crap Posting
To join: Put these lines in your signature and don't post crap!
LizardCPP
LizardCPP
If your domain name is gamedev.co.uk then you should call your package uk.co.gamedev.packagename .... I think, everybody seam to name them after their domain backwards.

LizardCPP
Monty Python
Monty Python
Ah, thanks.

[edited by - Monty Python on November 28, 2003 10:19:40 AM]
GSACP: GameDev Society Against Crap Posting
To join: Put these lines in your signature and don't post crap!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.