coding style/convention question

B

bugbear

Does anyone have a convention (with reasons!)
for the order in which
public/final/static
appear in a declaration?

BugBear
 
H

HK

bugbear said:
Does anyone have a convention (with reasons!)
for the order in which
public/final/static
appear in a declaration?

Last time I used jikes, it had an option
which told you their preferred way.

Harald.
 
I

Ingo R. Homann

Hi,
Does anyone have a convention (with reasons!)
for the order in which
public/final/static
appear in a declaration?

Checkstyle has the convention "public static final". AFAIK, it is also a
sun-convention.

Ciao,
Ingo
 
T

Thomas Weidenfeller

bugbear said:
Does anyone have a convention (with reasons!)
for the order in which
public/final/static
appear in a declaration?

Reasons? The majority of reasons for coding style conventions are
subjective. The value of following a convention is to get a uniform,
known result and often not so much in a particular rule.

Some rules are there to avoid common language pitfalls, but for the
majority there are no technical reasons or very light technical reasons.

That said, I prefer the order

[public|protected|private] [static] [final] *type* *name*

Reason? Well, let me make some up :) Seriously, when dealing with a
class I am first interested if/how I can access a method or field, so
visibility (public, private, etc ...) should be first. Then I care if I
need an instance or not (static), and if I can only read or change
things (final).

Or in short, because of the following subjective reasons:

- I like it that way

- It improves readability

- It is more logical this way

- Many people do it the same way

/Thomas
 
B

bugbear

Thomas said:
bugbear said:
Does anyone have a convention (with reasons!)
for the order in which
public/final/static
appear in a declaration?


Reasons? The majority of reasons for coding style conventions are
subjective. The value of following a convention is to get a uniform,
known result and often not so much in a particular rule.

Some rules are there to avoid common language pitfalls, but for the
majority there are no technical reasons or very light technical reasons.

That said, I prefer the order

[public|protected|private] [static] [final] *type* *name*

Reason? Well, let me make some up :) Seriously, when dealing with a
class I am first interested if/how I can access a method or field, so
visibility (public, private, etc ...) should be first. Then I care if I
need an instance or not (static), and if I can only read or change
things (final).

Or in short, because of the following subjective reasons:

- I like it that way

- It improves readability

- It is more logical this way

- Many people do it the same way

Well, that all seems pretty well argued.

Thank you.

BugBear
 
T

Tim Tyler

bugbear said:
Does anyone have a convention (with reasons!) for the
order in which public/final/static appear in a declaration?

``Checks that the order of modifiers conforms to the suggestions in the
Java Language specification, sections 8.1.1, 8.3.1 and 8.4.3. The
correct order is:

1. public
2. protected
3. private
4. abstract
5. static
6. final
7. transient
8. volatile
9. synchronized
10. native
11. strictfp

- http://checkstyle.sourceforge.net/config_modifier.html
 
R

Roedy Green

Does anyone have a convention (with reasons!)
for the order in which
public/final/static
appear in a declaration?

there is an official order. See
http://mindprod.com/jgloss/codingconventions.html

--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm

Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
 
R

Roedy Green

- I like it that way

Idioms let you not have to think.

public-static-final is one word in my mind to mean an important
constant.

If someone called it a final static public constant I would have to
stop and think for a second about what that meant. I have enough
important things to think about for tiny extra burdens like that.

You do it for roughly the same reason you don't normally talk like
Yoda.


--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm

Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top