Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 715
corsiKa Avatar asked Sep 09 '10 16:09

corsiKa


People also ask

Is hyphen allowed in Java package name?

You are right, the simple answer is: You are NOT allowed to use the hypen in package names. If you have a unique package name build from a domainname containing a hyphen you have to translate it to the underscore.

How should you name packages Java?

Package names are written in all lower case to avoid conflict with the names of classes or interfaces. 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 .

Can package name Camelcase?

The package names do not follow camel casing or underscores or hyphens package naming convention.

Why do package names start with com?

Generally we android developer having practice to decide package name based on the domain name of a particular company. For example: Domain name: sun.com => Root package name something like : com.


1 Answers

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

like image 111
3 revs, 3 users 67% Avatar answered Sep 28 '22 07:09

3 revs, 3 users 67%