aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes JavaDoc private fields and methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "JavaDoc private fields and methods" Watch "JavaDoc private fields and methods" New topic
Author

JavaDoc private fields and methods

Kenny Johnson
Ranch Hand

Joined: Jan 01, 2007
Posts: 37
For the SCJD project, do you need to JavaDoc private fields and methods? It would seem using regular comments makes more sense, since these are private hence they are not to be exposed or known about to clients of the class. A javadoc is supposed to be an API reference so clients can use your code .. or am I getting this all wrong?
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2266
    
    3

Howdy, Kenny!

For the SCJD project, do you need to JavaDoc private fields and methods?


Well champ, I do think it is a good idea to write JavaDoc comments even for the private members, in order to ease maintenance. You don't have to include them in the documentation, but if you want to include them one day, they are already there. You can include, for instance, protected and public members.

It would seem using regular comments makes more sense, since these are private hence they are not to be exposed or known about to clients of the class.


You mean the // comments? Well, I myself don't like them. If they are used, then it means that you are having to explain your code, which is something the code should do on its own. The code should be as clean as possible, which means that the methods shouldn't be big (up to 15 excluding '{' and '}' should be enough) and variables should have a proper name (i.e. "serverReference" instead of "sRef"), as well as the methods.

I myyself included JavaDoc comments for all class members.


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5408
    
  13

Like Roberto I javadoc'ed every class member. I generated javadoc with the -package option (= shows only package, protected, and public classes and members), because I had a lot of package-private classes.

Although my code is clean and I use also proper variable names, I still use the // comment. For example, to add the jira-request number (when I have to add an extra line of code in an existing method), or to give a small explanation about the logic you followed (not only to help yourself remembering what you did several months later, but also to help your fellow developers understand what you did, without having to go through all lines of code to know what's going on),...


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JavaDoc private fields and methods