Java Packages
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?
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.
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.
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.
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;
package uk.gamedev.co.packagename;
or:
package co.uk.gamedev.packagename;
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
LizardCPP
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement