• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Consistancy in the capitalization of constants (Java Coding Conventions)

 
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
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • 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: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • 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
 
This. Exactly this. This is what my therapist has been talking about. And now with a tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic