Everyone knows that Java's constant naming convention is uppercase with underscores between words, like USERNAME
and ERROR_CODE
.
But should words/names that are normally spelled in CamelCase also use an underscore? Should SomeBrand™ be named SOME_BRAND
or SOMEBRAND
? The latter can be harder to read and it doesn't convey the proper case, but the former can be incorrectly read as separate words, especially with another word attached (e.g. SOME_BRAND_ID
). Is there an accepted convention? Maybe a third option?
Asked
Active
Viewed 1,786 times
1

shmosel
- 49,289
- 6
- 73
- 138
-
1`MCDONALDS` or `MC_DONALDS` - I'd say the latter holds to convention better and is easier to read. – ChiefTwoPencils Mar 18 '16 at 00:05
2 Answers
1
In your case, I would use SOMEBRAND
. One reason is the same that jonmecer mentioned, because SomeBrand is treated as one word in a sentence. In addition, SOME_BRAND
could lead to confusion about its definition: do you mean you are talking about "some brand", or are you talking about your one and only SomeBrand™? Putting it as SOMEBRAND
clears up any confusion in that regard.

17slim
- 1,233
- 1
- 16
- 21