Hyphenated company name in Java packages
Say you're working on the core module of the foo
project for BarBaz Incorporated. Your code fragment might look like this:
package com.barbaz.foo.core;
import com.barbaz.foo.util;
What would the convention be if your company's website was not barbaz.com
, but instead bar-baz.com
?
Solution 1:
The SUN-era Java Language Specification gives a suggested convention:
If the domain name contains a hyphen, or any other special character not allowed in an identifier (§3.8), convert it into an underscore.
But it's just a suggestion...
Solution 2:
I just looked through my browser's history, and in the last 2 months I haven't visited a single domain with a hyphen. So the convention is to rename the company.
Alternatively, leave out the hyphen, because BazBaz won't ever include Baz=Baz's code in their own.