• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Consistancy in the capitalization of constants (Java Coding Conventions)

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic