When declaring a member final it is good java coding style to use UPPER_CASE_NAME (true?) - TRUE
but what about when declaring final references: public static final dataClass Data; is the coding style also: DATA_CLASS or as above? - I haven't used much final object references, so cannot comment. Will wait for the others to respond.
Do anyone have a good reference to a java coding style guide (I have one from Sun but it's pretty old and surfacic)? - It is only the JDK version and the associated API that has changed over the past years, not the java language. So Sun's old coding standards would suffice.If you think you need to get hold of something more recent, then I think Max's book contains coding convention tips in his first chapter and also Kathy's SCJP guide.(the last 2 chapters are meant for SCJD).
- Are there points to loose on bad coding style? - Yes. I think so. Coding styles exist for better readability and maintainence.
When declaring a member final it is good java coding style to use UPPER_CASE_NAME (true?)
True. It's a coding habit inherited from C/C++ (at least) where constants are uppercased.
but what about when declaring final references:
public static final dataClass Data;
- is the coding style also: DATA_CLASS or as above?
I'm not sure I understand you, except to change the question as follows:
public static final DataClass DATA
- is the coding style also: DATA as above?
No for sure. But why? Here is my interpration: the final keyword will prevent you to reassign another DataClass object to your data reference, but the final keyword won't prevent the object itself to be modified. And as for most readers of Java code, the reference *is* the object ( ), uppercasing the reference would be misleading. Just my opinion.
Joined: May 04, 2004
Thanks for the responses. I just got hold of Max' Book today.
There is a link to a place on Javasoft homepage (if someone else are interested) that explains it all: