Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should JavaDoc go before or after a method-level annotation? [duplicate]

What is the recommended place to put JavaDoc for a method with an annotation? Before or after the annotation?

@Test
/**
 * My doc
 */
public void testMyTest(){

}

OR

/**
 * My doc
 */
@Test
public void testMyTest(){

}
like image 460
Freiheit Avatar asked Dec 21 '22 13:12

Freiheit


2 Answers

I don't think it matters but second format is better. annotations are part of the code and play crucial role per their usage pattern. Better to keep all code related entries together.

like image 123
Yogendra Singh Avatar answered Dec 23 '22 01:12

Yogendra Singh


The usual style seems to be to have the annotation after the Javadoc comment.

The reason is that the annotations are part of the code, not of the documentation - why should the documentation sit inbetween.

This may not be obvious for @Override and @Test, and of course there are documentation related annotations, too. But technically, annotations are Java code of a particular syntax.

like image 40
Has QUIT--Anony-Mousse Avatar answered Dec 23 '22 02:12

Has QUIT--Anony-Mousse