Commenting |
Comments are extremely important. Take some care to write accurate yet concise comments.
You should write comments for:
Comments for classes headers should use the Javadoc block comment style. For classes these should use the following style:
/** * Tell what the class does here as well as why and when you wrote it. * Let us know if there is something different than was specified in the * assignment (i.e., extra credit). * @author <your name here> */
If the method code is simple you do not need to comment in the method body. If the method body is complicated, you might want to add some comments to certain blocks of code that you deem to be complicated, e.g., the different branches of an if-else statement, or what a loop is accomplishing. Be careful not to overcomment!
For method headers the style is:
/** * Tell what the method should do (but not how!) * @param paramName -- what the parameter represents * Include an @param line for each parameter * @return what is returned * An @return line is needed if the method returns anything but void */
Commenting |