1

I'm searching the best way to make documentations with overloaded methods.

I have two methods:

/** * does something * @param A * @return result */ public String methodA(Type1 A); /** * does something * @param A * @return result */ public String methodA(Type2 A); 

Since both methods render the same thing, is it possible to centralize the doc on a method which would take Object arguments? Or is there a better way to do so?

7
  • 1
    Are you talking about javadoc? Commented Jun 18, 2013 at 8:52
  • You could use generics but I guess this is a bit heavy handed for centralising documentation! Commented Jun 18, 2013 at 8:53
  • @ Shreyos Adikari Yes, with JUnit. Commented Jun 18, 2013 at 8:53
  • The Javadoc has no such mechanism, no... One has to check for the method arguments. Commented Jun 18, 2013 at 8:55
  • 1
    You could use the stackoverflow.com/questions/5915992/… @link tag to link one of the methods to the other. This avoids redundancy of the actual documentation ("does something"). Commented Jun 18, 2013 at 9:00

1 Answer 1

1

I think that your original intention to write a kind of "generic" documentation does not work out of the box. You need to take care of the parameters and the return value at least.

Or is there a better way to do so ?

To avoid redundancy of the actual documentation, you can use the @link tag.

This is especially useful if the method requires a lot of documentation, like for example the Properties.load() methods.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.