shmosel
shmosel

Reputation: 50716

What's the proper constant naming convention for words stylized in CamelCase?

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?

Upvotes: 1

Views: 2504

Answers (2)

17slim
17slim

Reputation: 1243

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.

Upvotes: 1

jonmecer
jonmecer

Reputation: 721

According to sun each word should be separated by "_". Now when you type SomeBrand in a sentence, you would treat it as a word. So, I think SOMEBRAND works better. But then again, this is based on your company's policy.

Upvotes: 0

Related Questions