• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why do we need to put {@inheritDoc} since it is implicitly added

 
Ad Tan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just a thought, javadocs for methods that inherits or overrides will automatically be generated even if {@inheritDoc} is not specified. Of course in cases where you want to append onto parent's javadocs, {@inheritDoc} is the way to go.

Having said that, has anyone failed SCJD for not explicitly using {@inheritDoc} in methods that 100% retains the parent's javadocs?


The safe way of course is to manually add {@inheritDoc} in those places... just wondering if it is strictly necessary in SUN's terms.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ad,

I didn't know that it is implicitly added, so I added them each time. And to be really honest: it was my IDE (Eclipse) who added this javadoc comment each time I implemented a method

Kind regards,
Roel

 
Ad Tan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roel De Nijs wrote:I didn't know that it is implicitly added, so I added them each time. And to be really honest: it was my IDE (Eclipse) who added this javadoc comment each time I implemented a method

That's very kind for Eclipse to do that... netbeans doesn't

I'm not too sure what goes behind the scene... but when using javadoc utility in the most basic way, parent's javadoc (if present) will be generated if the method does not have it's own javadoc.

The only difference is the inclusion of an additional line:
--- Description copied from interface: XXX

I guess i'd prob add it to all relevant methods to be safe.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ad Tan wrote:I guess i'd prob add it to all relevant methods to be safe.

Better safe than sorry You certainly won't fail for it, but might lose some points in the section "Documentation".

Kind regards,
Roel
 
K. Tsang
Bartender
Posts: 3583
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ad,

I used netbeans for my projects. And for SCJD, better to explicitly add {@inheritDoc} to those methods. And you will get full marks for documentation.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic