Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding Sun Naming Convention

 
Zeng Wei Chu
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, is it mandatory to provide an all CAPS naming convention as long as fields had been defined with both static and final? For primitives & Strings, I have adopted the all CAPS convention. However, does this convention applies when its a mutable object?

For example,
My current naming:


Do it have to be like this:
 
Sundeep Nanua
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check this:

http://java.sun.com/docs/codeconv/html/CodeConventions.doc8.html

I think it should be in CAPS regardless of the data type
 
Robert James Liguori
Author
Ranch Hand
Posts: 553
5
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Excellent question... here's the link from the The Java Language Specification, Third Edition.

http://java.sun.com/docs/books/jls/third_edition/html/names.html#6.8.6

Here's part of the text, "The names of constants in interface types should be, and final variables of class types may conventionally be, a sequence of one or more words, acronyms, or abbreviations, all uppercase, with components separated by underscore "_" characters. ..."

Notice the use of the word *may*.

... and consider this constant (primitive type though):



Hmmm.... what's the true history/intent here (when it comes to the decision not to capitalize?)
[ June 12, 2008: Message edited by: Robert Liguori ]
 
Zeng Wei Chu
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply guys, I think i will adopt the CAPS and underscore convention for primitive constants only. Somehow it seemed unnatural to me to use constants naming convention on "final static" objects which are actually mutable.

But i guess i better document this decision in the choices.txt
[ June 11, 2008: Message edited by: Zeng Wei Chu ]
 
rinke hoekstra
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Zeng Wei Chu:
I think i will adopt the CAPS and underscore convention for primitive constants only. Somehow it seemed unnatural to me to use constants naming convention on "final static" objects which are actually mutable.

But i guess i better document this decision in the choices.txt


I did the same, and exactly for the same reason. But I did not put this decision in choices.txt. Maybe I should, but I found it a too minor issue to put it in there.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic