如何在Java中命名导入/导出包?

发布于 2024-10-20 12:15:47 字数 258 浏览 2 评论 0原文

我有一个导出/导入例程,它变得更大,我决定将包分成两个较小的包。

我尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

甜味超标? 2024-10-27 12:15:48

我通常使用 libapiutil 作为库。指示正在导入的内容的

内容包是为导入而设计的,因此包中的单词有些多余。

I usually use lib or api or util for libraries. Something which indicates what is being imported

Packages are designed for importing so the word in a package is somewhat redundant.

‘画卷フ 2024-10-27 12:15:48

我推荐 exp0rt imp0rt 以便看起来像 java 重命名(class into clazz)

I'd recommend exp0rt imp0rt in order to look like java renames (class into clazz)

自演自醉 2024-10-27 12:15:48

一种选择是使用单词的缩写。这类似于 impexp
或者,如果您已经为 imp/exp 功能指定了名称,则可以将其用作包名称,例如 if.myinterfacename

An option is to use the abbreviation of the words. This would be something like imp and exp.
Or if you have given the imp/exp functionality a name, you could use that as the package name, like if.myinterfacename.

清风疏影 2024-10-27 12:15:48

是的,import是java中的关键字,你必须为你的包裹想出另一个名字。

Yes, import is a keyword in java, you will have to think of another name for your package.

南薇 2024-10-27 12:15:47

我们正在使用出口商/进口商。

或者您可能想使用诸如 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.

爱殇璃 2024-10-27 12:15:47

为此编写单独的导入器/导出器

希望这会有所帮助!

Write separate importer/exporter for this

Hope this will help!

零度℉ 2024-10-27 12:15:47

我可能会选择 importpkg / exportpkgbusinessimport / businessexport 只是为了坚持名称“import”,如果这是最能描述包裹内容的词。另一种方法是遵循长标识符的命名约定,并在末尾删除元音:imprt

I would probably go with importpkg / exportpkg or businessimport / 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文