Javadoc @return tag comment duplication necessary?

If you (like me) really don’t like to violate DRY, then this is one of the most important lines of the javadoc ref:

It is possible to have a comment with only a tag section and no main description.

(@see http://docs.oracle.com/javase/7/docs/technotes/tools/solaris/javadoc.html#tagsection)

So it is perfectly valid (and working) for simple methods to write your javadoc like:

/**
* @return the name of the object
*/
public String getName();

So you could even write something like this:

/**
* @return the n-th element of the object
*
* @param n index of element to get
*/
public String get( int n );

Which is (after a little getting to know each other) more readable in source and better maintainable as the longer form which violates DRY.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)