• Post Reply Bookmark Topic Watch Topic
  • New Topic

Package naming convention  RSS feed

 
pradeep chellappan
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am not really able to really appreciate the package naming mechanism in java.
What i mean is, java creators thought that by using internet domain in the reverse,the package hierarchy followed by any user will not clash with
any other user's package hierarchy.
For example,if a developer has used a package hierarchy something like this:
com.Kiran.mydirectory.mysubdirectory.
Then can't there be any other developer working in a different module use the pacakge/willing to use(but can't because other developer has already used the package hierachy).
Can somebody expalin on this.

Advance thanks.
Pradeep
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what you are trying to say, especially in "Then can't there be any other developer working in a different module use the pacakge/willing to use(but can't because other developer has already used the package hierachy)."

Consider the package:

org.apache.commons.collections

Are you worried someone outside of apache is going to create a package with that name? Or that two developers within apache might simulatenously choose that very package name?
 
Jaime M. Tovar
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Packages conventions in java are just a suggestion, you can have all your java classes in the same package (not recommended but you can). And it was created as a way to fulfill a OOP requirement/best practice to have a mechanism to group and organize classes.

And it isn�t infallible, just as class naming convention. You can create a class with exactly the same name as your partner in front of you and they will clash when you get your code together. But lets say you are working in the project.net part of the project and he is working in the project.blogic part. Then both of you can have an Address class. Meaning that you are working in the internet address and he is working in the physical address of a customer.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!