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 methods it is dififcult for anyone else than the author to guess the purpose of the method except by looking at the code and eventually the code called by this method.
Remediation
You should add JavaDoc Comments for all methods (Except Private Methods,getters and setters, Empty Constructors and Methods overriding another method) of the application.
Violation Code Sample
public static String getName(String[] args) throws NoNameException { //Violation if(args.length == 0) { throw new NoNameException(); } else { return args[0]; } }
Fixed Code Sample
/** * Extracts the user's name from the input arguments. * * Precondition: 'args' should contain at least one element, the user's name. * * @param args the command-line arguments. * @return the user's name (the first command-line argument). * @throws NoNameException if 'args' contains no element. */ public static String getName(String[] args) throws NoNameException { if(args.length == 0) { throw new NoNameException(); } else { return args[0]; } }
Reference
https://developer.atlassian.com/server/confluence/javadoc-standards/
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.