Sun's Java style rules specify that accessors should follow the getX/setX pattern, and most Java API mathods follow this...
except for some very common exceptions such as:
String length()
enum name() [NB new to 1.5, so not a legacy!]
ArrayList size()
etc
It seems that there is another pattern operating here: methods that access a private field which will never be set from outside the class are simply named after the field.
Has anyone seen this documented? Is there some other explanation?
Question
JamesCherrill
Sun's Java style rules specify that accessors should follow the getX/setX pattern, and most Java API mathods follow this...
except for some very common exceptions such as:
String length()
enum name() [NB new to 1.5, so not a legacy!]
ArrayList size()
etc
It seems that there is another pattern operating here: methods that access a private field which will never be set from outside the class are simply named after the field.
Has anyone seen this documented? Is there some other explanation?
Link to comment
Share on other sites
10 answers to this question
Recommended Posts