Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java Help > Naming conventi...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 8 Topic 15883 of 16566
Post > Topic >>

Naming conventions for constants

by Karsten Wutzke <kwutzke@[EMAIL PROTECTED] > Mar 15, 2008 at 03:38 PM

Hello,

Sun and other sources state that constants should be named in
ALL_UPPER_CASE. This is ok, but what the hell is a constant?

Someone stated some time ago constants only apply to 'static final
fields' being simple types like int, String, Color etc.

What if I have a

protected static final Properties ... = new Properties()?

Write the field in ALL_UPPER_CASE like PRP or PROPS? It it just me or
do I get eye cancer here?

Aren't constants declarations which involve mostly immutable cl*****/
objects? The int in itself can't be changed once declared final, final
instances of some class are basically mutable given certain access
methods, so String's, awt.Color's should *not* be called constants
strictly, but can be considered immutable. Other cl***** used like
collections, Properties and custom cl***** are definitely inherently
mutable and (to answer the above question myself) should not be
declared in UPPER_CASE.

I'm unsure for which declarations this convention is meant for...

What about final parameters? What about final local variables?
Remember these cannot be declared as static, so logically 'constants',
if said to be static only, never apply to parameters and local
variables...

Can anyone confirm that please? Discussions welcome.

Karsten
 




 8 Posts in Topic:
Naming conventions for constants
Karsten Wutzke <kwutzk  2008-03-15 15:38:57 
Re: Naming conventions for constants
ram@[EMAIL PROTECTED] (S  2008-03-16 02:13:48 
Re: Naming conventions for constants
Mark Space <markspace@  2008-03-15 19:33:05 
Re: Naming conventions for constants
Roedy Green <see_websi  2008-03-16 06:03:08 
Re: Naming conventions for constants
Karsten Wutzke <kwutzk  2008-03-15 23:25:55 
Re: Naming conventions for constants
Karsten Wutzke <kwutzk  2008-03-15 23:28:21 
Re: Naming conventions for constants
Lew <lew@[EMAIL PROTEC  2008-03-16 09:21:49 
Re: Naming conventions for constants
Roedy Green <see_websi  2008-03-17 10:04:03 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 15:46:13 CST 2008.