2

Is it good practice to use a free website as package identifier if I do not have a real website? EG com.weebly.vikarjramun.myapp.myactivity Just wondering...

vikarjramun
  • 353
  • 2
  • 9
  • Possible duplicate of [What is the point of Java's package naming convention?](http://programmers.stackexchange.com/questions/117030/what-is-the-point-of-javas-package-naming-convention) – gnat Aug 18 '16 at 18:11
  • 2
    The purpose of using a domain name is to have uniqueness. Whether it's a free website or not is largely irrelevant. Whether you own the domain or not is very relevant, however. – Robert Harvey Aug 18 '16 at 18:14

2 Answers2

3

A little background:

Companies use their reversed Internet domain name to begin their package names—for example, com.example.mypackage for a package named mypackage created by a programmer at example.com.

The reason of that convention is to avoid colissions since, jar files are treated as folders. If someone in a project have two jars with the same package hierarchy there maybe colissions.

This answer to a similar question offers good free, more ellegant alternatives using things that you control, like your GitHub repository or your StackExchange profile to give uniqueness to your package hierarchies if you don't own a domain.

Tulains Córdova
  • 39,201
  • 12
  • 97
  • 154
3

The issue is not whether the site is free or not, but whether you control the domain or subdomain in question. If you don't control the domain name, there is a risk that you may lose it to somebody else, and if that somebody else is also a Java developer, you may end up with a package name collision. If you do own the domain name, it doesn't even need to be in use - as long as you own it, you can be pretty sure nobody else will use it as a namespace.

If the domain is a subdomain under a domain owned by someone else, you probably don't have any guarantee that you wont lose it, e.g. if the company closes shop and someone else buys the assets.

JacquesB
  • 57,310
  • 21
  • 127
  • 176
  • Thanks for your answer! Both you and Tulains Cordova answered my question, but as he gave some alternatives, I selected his answer – vikarjramun Aug 18 '16 at 19:27