I really like well documented code. But there are lots of duplications in the documentation, since the basic information and examples should be available for the properties, the setters/getters and in constructors (also see Simple Getter/Setter comments).
Is there a way to avoid duplication of JavaDocs? The only idea I had is using {@link #function()}
and link to a part in the JavaDocs that contains more information.
Here is an imaginary example:
package com.stackoverflow.tests;
/**
* An Event ...
*/
public class Event {
/**
* The date the event takes place.
* Needs to be in <a href="https://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a> format.
*
* <h2>Examples:</h2>
* <ul>
* <li>{@code 2016-03-19}</li>
* <li>{@code 2016-03-19T05:54:01+00:00}</li>
* <li>{@code 2016-W11} - i.e. week 11 of 2016</li>
* </ul>
*/
private String date;
/**
* Creates an event initializing it with the date and location the event takes place.
* @param date
* Date in <a href="https://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a> format. Examples:
* <ul>
* <li>{@code 2016-03-19}</li>
* <li>{@code 2016-03-19T05:54:01+00:00}</li>
* <li>{@code 2016-W11} - i.e. week 11 of 2016</li>
* </ul>
* @param location
* Location ...
*/
public Event(final String date, final String location) {
this.date = date;
}
/**
* The date the event takes place.
* @return
* Date in <a href="https://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a> format.
*/
public String getDate() {
return date;
}
/**
* Updates the date the event takes place using an ISO 8601 formatted String.
* @param date
* Date in <a href="https://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a> format. Examples:
* <ul>
* <li>{@code 2016-03-19}</li>
* <li>{@code 2016-03-19T05:54:01+00:00}</li>
* <li>{@code 2016-W11} - i.e. week 11 of 2016</li>
* </ul>
*/
public void setDate(String date) {
this.date = date;
}
}