什么是没有域关联的约定Java包的名字呢? [英] What's the convention for java package names without a domain association?

查看:126
本文介绍了什么是没有域关联的约定Java包的名字呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找不到这么Q / A,回答我的确切的问题,所以我想我会发布它,看看有什么回来。

至于命名规则也适用于Java包,据我所知,它应该是反向域名: com.whatever.stuff 和我有关规则没有混合的情况下,连字符,关键字等。

我也看到了Java语言规范第7.7(独特的 - 封装 - 名称)。据我所知,从Java规则是使用反向域名,以确保独特性......如果你没有一个,去得到一个:

通过先有(或属于,有一个组织)的互联网域名,如sun.com形成独特的包名 - 第7.​​7节

所以,如果我在炮击了钱一个域名没有兴趣,我不属于一个公司的名字我可以搭载过的,有没有什么部分是我失踪的命名约定应遵循?我想我可以去它命名为任何唯一的名称,我觉得在这一点上,但我只是想知道如果我错过了什么。

注意:我要释放我的包,其他开发人员使用的,所以我不想只是做一些事情在我的系统是工作的事,但如果可能的话更标准

我加入了Android的标签,因为Java包我要编写将会在Android应用程序中使用,不知道是否有不同意见的Andr​​oid开发者。

解决方案

如果你将要发布很多东西,我真的建议得到一个域名。另一种选择不过是使用您的电子邮件:如 bob@gmail.com 将成为 com.gmail.bob 。这比使用域名不常见,但仍然被一些人做的,仍然可以确保唯一性。

I can't find a Q/A on SO that answers my exact question, so I figure I'd post it and see what comes back.

As far as the naming convention goes for Java packages, I understand that it's supposed to be the reverse domain name: com.whatever.stuff and I get the rules about no mixed case, hyphens, keywords, etc.

I've also read section 7.7 (Unique-Package-Names) of the Java Language Specification. As far as I can tell, the rules from Java are to use the reverse domain to insure uniqueness... and if you don't have one, go get one:

You form a unique package name by first having (or belonging to an organization that has) an Internet domainname, such as sun.com. - Section 7.7

So if I'm not interested in shelling out the money for a domain name, I don't belong to a company whose name I can piggyback off of, is there any part of the naming convention that I'm missing that should be followed? I'm thinking I can just go name it whatever unique name I feel like at this point, but I was just wondering if I was missing anything.

Note: I would like to release my package for other developers to use, so I didn’t want to just do something that worked on my system, but something more standard if possible.

I added the android tag because the java packages I'm going to be writing are going to be used in an Android application, wasn't sure if there were different opinions from android developers.

解决方案

If you are going to be distributing a lot of stuff, I would really suggest getting a domain name. Another alternative however would be to use your e-mail: e.g. bob@gmail.com would become com.gmail.bob. This is less common than using domain names but is still done by some and still ensures uniqueness.

这篇关于什么是没有域关联的约定Java包的名字呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆