如何在Java中命名导入/导出包?
我有一个导出/导入例程,它变得更大,我决定将包分成两个较小的包。
我尝试使用 org.yourcompany.business.export
...工作正常!不幸的是,由于 Java 中的保留关键字 import
,无法使用名为 org.yourcompany.business.import
的相反包。
如何命名您的导入/导出包?
谢谢你!
I have an export / import routine which becomes bigger and I decided to split up the packages into two smaller.
I tried to use org.yourcompany.business.export
...works fine! Unfortunately the opposite package with the name org.yourcompany.business.import
is not possible to use due to the reserved keyword import
in Java.
How do you name your import / export packages?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
我通常使用
lib
或api
或util
作为库。指示正在导入的内容的内容包是为导入而设计的,因此包中的单词有些多余。
I usually use
lib
orapi
orutil
for libraries. Something which indicates what is being importedPackages are designed for importing so the word in a package is somewhat redundant.
我推荐 exp0rt imp0rt 以便看起来像 java 重命名(class into clazz)
I'd recommend exp0rt imp0rt in order to look like java renames (class into clazz)
一种选择是使用单词的缩写。这类似于
imp
和exp
。或者,如果您已经为 imp/exp 功能指定了名称,则可以将其用作包名称,例如
if.myinterfacename
。An option is to use the abbreviation of the words. This would be something like
imp
andexp
.Or if you have given the imp/exp functionality a name, you could use that as the package name, like
if.myinterfacename
.是的,import是java中的关键字,你必须为你的包裹想出另一个名字。
Yes, import is a keyword in java, you will have to think of another name for your package.
我们正在使用出口商/进口商。
或者您可能想使用诸如 Exchange.in 和 Exchange.out 之类的东西,因为这通常是导入器/导出器的目的 - 交换数据。
We're using exporter/importer.
Or maybe you want to use something like exchange.in and exchange.out, since that's normally the purpose of an importer/exporter - to exchange data.
为此编写单独的导入器/导出器
希望这会有所帮助!
Write separate importer/exporter for this
Hope this will help!
我可能会选择
importpkg
/exportpkg
或businessimport
/businessexport
只是为了坚持名称“import”,如果这是最能描述包裹内容的词。另一种方法是遵循长标识符的命名约定,并在末尾删除元音:imprt
。I would probably go with
importpkg
/exportpkg
orbusinessimport
/businessexport
just to stick to the name "import", if that is the word best describing the content of the package. An alternative would be to follow the naming convention for really long identifiers, and drop a vowel in end:imprt
.