Naming convention when casually referring to methods in Java
Is there a Java convention to refer to methods, static
and otherwise, any specific one or the whole overload, etc?
e.g.
String.valueOf
- referring to all overloads ofstatic valueOf
String.valueOf(char)
- specific overload, formal parameter name omittable?
String.split
- looks like a static method, but actually an instance method- Maybe
aString.split
is the convention? - Or maybe
String().s开发者_如何转开发plit
?
- Maybe
String#split
- I've seen this HTML anchor form too, which I guess is javadoc-influenced
Is there an authoritative recommendation on how to clearly refer to these things?
Using Class.methodName
to refer to all overloads and Class.methodName(type)
to refer to a specific overload is indeed the convention (as recommended by sun in this style guide for javadocs). However there is no convention to distinguish between static and non-static methods (though aString.split
would make sense).
Depends on the context where you'd like to refer them. I myself tend to use Javadoc-style links everywhere (in Javadocs, my blog, forum posts, etcetera) and prefer to make them clickable as well, although admittely not consistently with method arguments when used outside Javadocs (I am a bit too lazy in this, Eclipse offers autocompletion of @link
tags ;) ). With regard to authoritative recommendations, there's as far as I know only the Javadoc linking recommendation.
精彩评论