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

Consistancy in the capitalization of constants (Java Coding Conventions)

 
Hubert Stroebitzer
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

I hate to ask this question.

I haven't found an answer in the forum so I will have to ask this detail question.

As far as I understood the java coding conventions they say about constants that it's not an error to captialize or not capitalize them as far you do it consistent. So I decided for my project to capitalize them. And they look like this:



So far so good. I think I do nothing harmful.

And now this:


Hmmmm. I hate it. What do you think about this? Do you think this will cost my points?

Regards don_huberto
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Hubert,

I think I do nothing harmful.
I would expect DATA_SECTION_POSITION (instead of DATASECTIONPOSITION), because seperate words get seperated with an underscore.

Do you think this will cost my points?
Certainly not! I capitalized my constants too (with underscore to separate the words) and the serial version UID was just cased like yours. And as a little quiz: can you think of any other constants in Java which are not capitalized?

Kind regards,
Roel
 
Hubert Stroebitzer
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi Roel

Thank you for your quick answer.

DATA_SECTION_POSITION => You are right

And the quiz: Hmmm. No. I reflected on it. But... hmmm... no. Please tell me.

Kind regards

Hubert
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at classes Color (each color constant has both a lower case and upper case variant) and Double (NaN constant). These are certainly the most commonly used (and known) ones. If you want to impress other ones with this knowledge, simply have a look at the constant field values
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic