I have a lots of class member variable. Each of them is important and would ideally require a comment explaining what it is about. If I try to add element comment to each of them, it end up looking something like :

/**
 * 
 */
private int[] violationCounterRise = new int[Consts.NUMBER_OF_PMU];
/**
 * 
 */
private String eSeverity;
/**
 * 
 */

And so on .. which makes code very messy and unreadable. Is there any other way to add javadoc comments to avoid clumsiness in this particular scenario ?

有帮助吗?

解决方案

No, there isn't. However, inserting a blank line may actually help readability.

/**
 * 
 */
private int[] violationCounterRise = new int[Consts.NUMBER_OF_PMU];

/**
 * 
 */
private String eSeverity;

Also, consider that JavaDoc for private fields is generated only if you enable the -private option. Since private fields will only matter when looking at the source code, you might not need to generate them in the first place, in which case //-style comments would work too.

Finally, think about why you have so many member variables in the first place. It may be the case that your class violates the Single Responsibility Principle and needs refactoring.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top