javanamespacesnaming-conventions

Do you really use your reverse domain for package naming in 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?


Solution

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

    This scheme does two important things:

    (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.

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

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

    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).