I've just learnt about, and am now trying to implement javadocs.
Is there a way to re-use a javadoc which you have already written, say for example when you overload a method to take more parameters?
I ask because I have done exactly this: I wrote a method which took 7 parameters:
/**
* @param a explanation a
* @param b explanation b
* @param c explanation c
* @param d explanation d
* @param e explanation e
* @param f explanation f
* @param g explanation g
*/
public void myMethod(int a, int b, int c, int d, int e, int f, int g)
{
//Whatever
}
Then I added and overloaded version which accepted all the same parameters, plus an additional 3 (for a total of 10 parameters).
/**
* @param a explanation a
* @param b explanation b
* @param c explanation c
* @param d explanation d
* @param e explanation e
* @param f explanation f
* @param g explanation g
* @param h explanation h
* @param i explanation i
* @param j explanation j
*/
public void myMethod(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j)
{
//Whatever
}
I copied and pasted the existing javadoc from the 7-parameter version for the overloaded 10-parameter version, and elaborated on it.
It takes up a huge amount of space, and I can't help but feel like I'm missing something.
I have looked at the Oracle documentation, but if it is in there, I haven't spotted it yet.
I am aware that there are ways to reference variables in the javadoc with techniques such as {@code someparam}
, so I think it is reasonable to assume that there may be a way to do this.
In my head I have a vision of something like:
/**
* {@docstring theOtherVersionOfThisMethod}
* @param h explanation h
* @param i explanation i
* @param j explanation j
*/
public void myMethod(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j)
{
//Whatever
}