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

variable naming, private final statics

 
Ian Stone
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have written a class which defines a bunch of
constants which are private to the implementation
of that class, ie. declared as

private static int[] foo

I know that the usual conventions guide that public
defined class constants should be capitalized (and
perhaps make use of underscores for longer names)
but is it conventional or unorthodox to use capitalization
in the naming of private final variables within a class
definition.

what is the gut feeling about this?

thanks in advance,

~ IanS
 
Saket Barve
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Technically speaking, you will not have committed any mistake. Indeed, your code will complie and give appropriate results (based on your logic).

From readability point of view and following coding standards, it'd be advisable to follow the norms.

Regards,
Saket
 
MenPorul Arvalan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ian,
Whether it is a public or private it is better to follow the coding conventions......In my view it is always better to have tne entire final static variable capitalized.

Eg: private static final String COLOR_RED = "redColor";
 
Mahesh Bhatt
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ian.

It is always the best practice to use the conventions, It makes the code easy to read as well as if makes others understand the code when they use it. However when we talk about the specific area that you have asked in your post, It doesn't make a difference. The code will anyways compile if the logic and syantax is correct.

regards
prashant
 
Ian Stone
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the answers.

I've adopted capitalization for the declaration of my
private final variables since that seems to be the
adopted practice regardless of access scope for class
constants.

thanks again for the help/advice.

~IanS
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I'll propose a new keyword to Sun ... let's call final static variables finatics.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic