<i id='FWYdM'><tr id='FWYdM'><dt id='FWYdM'><q id='FWYdM'><span id='FWYdM'><b id='FWYdM'><form id='FWYdM'><ins id='FWYdM'></ins><ul id='FWYdM'></ul><sub id='FWYdM'></sub></form><legend id='FWYdM'></legend><bdo id='FWYdM'><pre id='FWYdM'><center id='FWYdM'></center></pre></bdo></b><th id='FWYdM'></th></span></q></dt></tr></i><div id='FWYdM'><tfoot id='FWYdM'></tfoot><dl id='FWYdM'><fieldset id='FWYdM'></fieldset></dl></div>

        <small id='FWYdM'></small><noframes id='FWYdM'>

      1. <legend id='FWYdM'><style id='FWYdM'><dir id='FWYdM'><q id='FWYdM'></q></dir></style></legend>
        <tfoot id='FWYdM'></tfoot>
          <bdo id='FWYdM'></bdo><ul id='FWYdM'></ul>

        你真的在java中使用你的反向域来命名包吗?

        Do you really use your reverse domain for package naming in java?(你真的在java中使用你的反向域来命名包吗?)
          <i id='gpMu4'><tr id='gpMu4'><dt id='gpMu4'><q id='gpMu4'><span id='gpMu4'><b id='gpMu4'><form id='gpMu4'><ins id='gpMu4'></ins><ul id='gpMu4'></ul><sub id='gpMu4'></sub></form><legend id='gpMu4'></legend><bdo id='gpMu4'><pre id='gpMu4'><center id='gpMu4'></center></pre></bdo></b><th id='gpMu4'></th></span></q></dt></tr></i><div id='gpMu4'><tfoot id='gpMu4'></tfoot><dl id='gpMu4'><fieldset id='gpMu4'></fieldset></dl></div>

            1. <tfoot id='gpMu4'></tfoot>
                <tbody id='gpMu4'></tbody>
              <legend id='gpMu4'><style id='gpMu4'><dir id='gpMu4'><q id='gpMu4'></q></dir></style></legend>
              • <bdo id='gpMu4'></bdo><ul id='gpMu4'></ul>

              • <small id='gpMu4'></small><noframes id='gpMu4'>

                  本文介绍了你真的在java中使用你的反向域来命名包吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  很久以前,我一直认为,在java中,为包命名反转你拥有的域是愚蠢和尴尬的.

                  For a long time ago, I have thought that, in java, reversing the domain you own for package naming is silly and awkward.

                  您在项目中使用哪个包命名?

                  Which do you use for package naming in your projects?

                  推荐答案

                  一旦你理解了约定为什么存在,它就不应该感到愚蠢或尴尬.

                  Once you understand why the convention exists, it shouldn't feel silly or awkward in the least.

                  这个方案做了两个重要的事情:

                  This scheme does two important things:

                  • 您的所有代码都包含在其他人不会与之发生冲突的包中.您拥有自己的域名,因此它是孤立的.如果我们没有这个约定,很多公司都会有一个实用程序".包,包含StringUtil"、MessageUtil"等类等等.如果你试图使用其他人的代码,这些很快就会发生冲突.

                  • All of your code is contained in packages that no one else will collide with. You own your domain name, so it's isolated. If we didn't have this convention, many companies would have a "utilities" package, containing classes like "StringUtil", "MessageUtil" etc. These would quickly collide if you tried to use anyone else's code.

                  逆向"它的性质使得顶层的类目录布局非常狭窄.如果您展开一个 jar,您将看到com"、org"、net"等目录,然后在每个目录下显示组织/公司名称.

                  The "reverse" nature of it makes class-directory layout very narrow at the top level. If you expand a jar, you'll see "com", "org", "net", etc dirs, then under each of those the organization/company name.

                  (于 2021 年添加)如今,当这种类型的包命名用于第三方库时,这一点变得更加重要,这些库在构建过程中被引入,并且如果名称不是唯一的,则很容易发生冲突.如果每个人都遵守相同的约定,就不会发生意外碰撞.

                  (added in 2021) This is even more important nowadays when this type of package naming is used for third-party libraries which are pulled in transitively during builds and could easily conflict if the names were not unique. If everyone adheres to the same convention, there will be no accidental collisions.

                  (2021 年添加)相同的命名约定可用于应用商店中的应用程序 ID,以确保唯一性.

                  (added in 2021) The same naming convention can be used for application ids on an app store to ensure uniqueness as well.

                  我们通常不会扩展 jar,但在早期的 java 开发中,这很重要,因为人们使用扩展的 dir 结构来进行小程序.

                  We usually don't expand jars, but in early java development, this was important because people used expanded dir structures for applets.

                  但是,现在这很好,因为源代码目录结构具有非常自上而下"的结构.感觉.您从最通用的(com、org、net...)到不太通用的(公司名称)再到更具体的(项目/产品/lib 名称).

                  However, this is nice now as source code dir structures have a very "top-down" feel. You go from the most general (com, org, net...) to less general (company name) to more specific (project/product/lib name).

                  这篇关于你真的在java中使用你的反向域来命名包吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How can I detect integer overflow on 32 bits int?(如何检测 32 位 int 上的整数溢出?)
                  Local variables before return statements, does it matter?(return 语句之前的局部变量,这有关系吗?)
                  How to convert Integer to int?(如何将整数转换为整数?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在给定范围内创建一个随机打乱数字的 int 数组)
                  Inconsistent behavior on java#39;s ==(java的行为不一致==)
                  Why is Java able to store 0xff000000 as an int?(为什么 Java 能够将 0xff000000 存储为 int?)

                  1. <small id='EGAvX'></small><noframes id='EGAvX'>

                      <bdo id='EGAvX'></bdo><ul id='EGAvX'></ul>
                        <tbody id='EGAvX'></tbody>
                        <legend id='EGAvX'><style id='EGAvX'><dir id='EGAvX'><q id='EGAvX'></q></dir></style></legend>
                        <i id='EGAvX'><tr id='EGAvX'><dt id='EGAvX'><q id='EGAvX'><span id='EGAvX'><b id='EGAvX'><form id='EGAvX'><ins id='EGAvX'></ins><ul id='EGAvX'></ul><sub id='EGAvX'></sub></form><legend id='EGAvX'></legend><bdo id='EGAvX'><pre id='EGAvX'><center id='EGAvX'></center></pre></bdo></b><th id='EGAvX'></th></span></q></dt></tr></i><div id='EGAvX'><tfoot id='EGAvX'></tfoot><dl id='EGAvX'><fieldset id='EGAvX'></fieldset></dl></div>

                            <tfoot id='EGAvX'></tfoot>