Suns 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, 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?
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
Recommended Answers
Jump to PostVery interesting. Thanks JC.
I think it is undocumented. I never read about the design pattern of method from a textbook. Presumption !!!. I am pasting a link http://www.javacamp.org/designPattern/ may be some …
Jump to PostHi adatapost. Sorry if I caused any confusion by using the word "pattern", I should have said "naming convention". Curious, isn't it?
Yes, it is. What about the name of static constructor? :)
All 8 Replies
kvprajapati
1,826
Posting Genius
Team Colleague
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
kvprajapati
1,826
Posting Genius
Team Colleague
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
kvprajapati
1,826
Posting Genius
Team Colleague
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
Ezzaral
2,714
Posting Sage
Team Colleague
Featured Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.