Home   Help Search Login Register  

Author Topic: Java package names  (Read 3556 times)

0 Members and 1 Guest are viewing this topic.

Offline Slapstick

  • Members
  • *
Java package names
« on: 25 Mar 2012, 06:26:27 »
This question doesn't seem to fit in anywhere else, and I couldn't find any discussion on the topic, so I thought I would ask it here.

I bought Take on Helicopters just so I could start working with the TKOH/A3 Java API. However, the usual problem with naming things rears its ugly head. The usual convention when naming Java packages is to use the domain name of the organization releasing the packake as the "package" name, i.e. com.bistudio.jniscripting.

However, since many people won't have a domain name registered, and OFPEC already has a "tag" registry set up I would like to propose that people with registered OFPEC tags can use the OFPEC domain in their package names. For example, I've just registered the tag "slap", so ideally I would be permitted to use the Java package name com.ofpec.slap and release Java code with no fear of naming conflicts.

Since OFPEC has a name registry already set up, this seems like a natural solution.
There are only two hard problems in computer science: cache invalidation and naming things.

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Java package names
« Reply #1 on: 25 Mar 2012, 11:21:11 »
I personally know nothing about Java code, but this sounds like an excellent initiative/idea. I'm guessing the point with using domain names for naming packages is to make it possible to track the creator, yeah? Since the OFPEC tags include user name and contact info, that should work just fine as a way of keeping track of people.

Although, since it's just a naming convention (not a necessary part of the code), I don't know how many are going to follow it - people have a hard enough time tagging their work in the first place. :(

Still, sounds like a good initiative! Someone more Java-savvy want to butt in from the staff?

Wolfrug out.

"When 900 years YOU reach, look as good you will not!"

Offline Slapstick

  • Members
  • *
Re: Java package names
« Reply #2 on: 26 Mar 2012, 19:54:13 »
It is not so much to identify the author/creator, but simply a way to avoid naming conflicts between Java classes released by different authors.  For identification purposes the author should "sign" their jar (Java ARchive) file with an SSL certificate. So I might release some code using com.ofpec.slap and some code using my vanity domain, but everyone will know that it is my code if I sign my jar files.  Further, no one will be able to modify my Jar files as the digital signature will no longer match and Java won't even load the code.

Of course, as you say, it is just a convention and even in the Java world not all organizations follow it, or worse use domains they don't own as their package names.  That is why I thought I should ask first. I am getting ready to release some sample code and I need to decide on my package naming conventions.

Cheers,
Slapstick
There are only two hard problems in computer science: cache invalidation and naming things.

Offline Slapstick

  • Members
  • *
Re: Java package names
« Reply #3 on: 31 Mar 2012, 23:07:25 »
Well, I was hoping to generate a little more discussion on naming conventions for Java packages.  Can I assume the lack of disagreement is an implicit ok?

The only objection I can think someone might have is the OFPEC admins want to reserve the com.ofpec.* namespace and would prefer other people use something like com.ofpec.tags.*. But I would also think that if the OFPEC admins wanted a reserved namespace they would have registered their own tag!

I am getting to the point of deploying code and I have to decide on a naming convention soon. So unless I'm told to cease and desist I'll just try to come up a with a reasonable set of "best practices".
There are only two hard problems in computer science: cache invalidation and naming things.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: Java package names
« Reply #4 on: 01 Apr 2012, 09:52:08 »
My only thought on this is: if this is used simply as a variable naming convention, does the com.domain part need to be a real domain? If not, why not save your fingers and just go with com.slap.whatever?

If it does need to be a real domain, then yes, it makes sense to keep the tags associated with OFPEC.

Also, the admins do have a tag: OFPEC_ of course :) Which would make it com.ofpec.ofpec.whatever, but we'll deal with that when the time comes.  ;)

Good initiative; I say go for it.  :good:

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Java package names
« Reply #5 on: 01 Apr 2012, 20:29:38 »
Hey Slapstick,

Didn't mean to not-reply to your message: it seems the staff area is filled with people completely ignorant of Java, myself included :D So no-one really had a lot to say, unfortunately.

But as mentioned: this is a good initiative, and since it needs to be a real domain, using OFPEC is probably much better than having some kind of invented/junk domain. I don't suppose you could type down a few words as to how this thing would work the best in terms of tags, namespaces and whatnot, so that we could produce some kind of guideline for people to follow?  ;) Unpaid slave labour from your side, of course.

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline Slapstick

  • Members
  • *
Re: Java package names
« Reply #6 on: 03 Apr 2012, 02:39:59 »
My only thought on this is: if this is used simply as a variable naming convention, does the com.domain part need to be a real domain? If not, why not save your fingers and just go with com.slap.whatever?
While you don't have to use a domain as the Java package name, if you do use a domain it is good form to own, or have permission to use that domain name.  While it is highly unlikely that the people that own slap.com or slapstick.com will release Java code for TKOH/A3, it is a good idea not to encroach on other people's property.

If I don't use a real domain name, say I just use slapstick.* for my packages, there is nothing that prevents others from using that package name as well; I'm not the only Slapstick in the world. At least if I use a domain I own, or have permission to use, I have a little more justification telling any encroachers to stop using my namespace.

Quote from: Wolfrug
So no-one really had a lot to say, unfortunately.
No news is good news ;)

Quote from: Wolfrug
I don't suppose you could type down a few words as to how this thing would work the best in terms of tags, namespaces and whatnot, so that we could produce some kind of guideline for people to follow?
I would be happy to, but I'm not sure what exactly you want. It would probably suffice to post a statement to the effect:
Quote
Authors who have a registered OFPEC tag are authorized to use the com.ofpec.<tagName> domain for their Java package names. All other uses of the com.ofpec Java namespace are reserved and may not be used for any purpose without prior written permission of the OFPEC administrators.

Also, do the OFPEC admins have any plans for setting up a Java Depot sometime in the future?  I have several suggestions for what that should entail as well :)
There are only two hard problems in computer science: cache invalidation and naming things.