aspose file tools*
The moose likes Beginning Java and the fly likes variable naming, private final statics Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "variable naming, private final statics" Watch "variable naming, private final statics" New topic
Author

variable naming, private final statics

Ian Stone
Greenhorn

Joined: Sep 15, 2004
Posts: 13
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

Joined: Dec 19, 2002
Posts: 229
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

Joined: Oct 27, 2004
Posts: 1
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

Joined: Sep 15, 2004
Posts: 88
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


Impossible is I M Possible
Ian Stone
Greenhorn

Joined: Sep 15, 2004
Posts: 13
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

Joined: Jan 29, 2003
Posts: 8791
I think I'll propose a new keyword to Sun ... let's call final static variables finatics.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: variable naming, private final statics