Rule Definition
There is no dispute that these comments contribute to a developer's understanding and help a developer write reliable applications more quickly. Without documenting classes and interfaces it is dififcult for anyone else than the author to guess the purpose of the class or interface except by looking at the code and eventually the code called by the methods in the class.
Remediation
Add JDK javadoc tool doc comments(/** documentation */ ) when preparing automatically generated documentation.
Violation Code Sample
Sample#1 package diag.doc001; // // @author PYG // public class KO_1_5ClassComment_2SLASH { } -------------------------------------------- Sample#2 package diag.doc001; /* * * @author PYG * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */ ---------------------------------------------- Sample#3 public class KO_2_5ClassComment_OneStar { } package diag.doc001; //** // * @author PYG // * public interface KO_1_5InterfaceComment_2Slash { } -------------------------------------------------------- Sample#4 /* * */ package diag.doc001; /* * @author PYG * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */ public interface KO_2_5InterfaceComment_OneStar { }
Fixed Code Sample
Remediation Sample#1 /** * @author PYG * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */ public interface OK_InterfaceComment { } --------------------------------------------------------------------- Remediation Sample#2 package diag.doc001; /** * @author PYG * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */ public class OK_ClassComment { }
Reference
https://www.tutorialspoint.com/java/java_documentation.htm https://www.oracle.com/technical-resources/articles/java/javadoc-tool.html
Related Technologies
JEE
Technical Criterion
Documentation - Automated Documentation
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.