1

I am adding new things to a class and I want to have a short info about that in comments. Like this:

/**
 *  Added in September, 2013
 *  ----more description---
 */
public String newA;
public int newB; 
public boolean newC
...etc

This way, a description is only available to newA object since its the first one under the doc comment.

Is there a way that I apply the same comment to all new attributes under the newA?

This only applies to attributes since I have no problem adding doc comments to classes and methods.

OcuS
  • 5,320
  • 3
  • 36
  • 45
sandalone
  • 41,141
  • 63
  • 222
  • 338

1 Answers1

1

If it's really a must-be in your project you can use annotations.

/**
 *  Added in September, 2013
 *  ----more description---
 */
public @interface SampleAnnotation {

}

@SampleAnnotation
int i;

@SampleAnnotation
boolean b;

@SampleAnnotation
String s;

However you should read about annotations performance first.

If the variables are of the same type you can use standard element comment by placing them in the same line.

/**
 *  Added in September, 2013
 *  ----more description---
 */
int i, j;
mat
  • 337
  • 1
  • 9
  • 1
    *What* exactly should he read about 'annotations performance', and where? – user207421 Sep 24 '13 at 10:30
  • Some benchmarks and use-cases. Especially that they are much slower on devices with Android < 4.0 - [benchmark](http://eclipsesource.com/blogs/2012/09/28/mythbuster-android-annotation-performance-unravelled/), so IMHO we should use it very carefully when targeting older devices. – mat Sep 24 '13 at 10:53
  • Hm, aren't annotation issue already fixed? Link: http://stackoverflow.com/questions/7417426/why-are-annotations-under-android-such-a-performance-issue-slow – sandalone Sep 24 '13 at 17:56
  • That link is about *frameworks that use annotation processing.* The question is about user-defined annotations for documentation purposes, which aren't processed at all. Your suggestion and link are therefore irrelevant. – user207421 Sep 25 '13 at 00:46