Originally posted by Javini Javono:
Question 1
Section 3.1.1 says that all source files should begin with Beginning Comments
containing the class name, version information, data, and copyright notice.
George, since you scored 100, did you use Beginning Comments?
Yes, I had a javadoc comment immediately before the class name in every source file (I only had one class (not counting inner classes) per source file). I didn't include the class name because that seems sort of silly as the javadoc comment appears immediately before the class declaration.
The first sentence of a javadoc comment has a special status since it will appear as the sole comment in summary section of the javadoc documentation. To help me remember this I always included a blank javadoc line after the first sentence to remind me that the first sentence would stand alone in the summary section. For example,
I used the @author and @version tags everytime, the @see tag if I felt it was appropriate.
Question 2
Section 4, on indentation, states:
1. Four spaces should be used as the unit of indentation. The exact construction
of the indentation (spaces verse tabs) is unspecified.
2. Tabs must be set exactly every 8 spaces (not 4).
From item 1, if I have a tab equivalent to four spaces, then it seems that
I violate the condition in item 2. Is Sun basically saying that I must not use any
tabs in the source file, and only use spaces?
I used 4 spaces of indentation. I used 8 spaces on the following lines if a long line had to be continued to following lines. My editor, TextPad, allowed automatic conversion of tabs to spaces so I was able to use tabs knowing that they would be converted to 4 spaces when the file was saved.
Question 3
It would make a lot of sense to use an automated tool to incorporate all the rules
in this document: Sun's Java Code Conventions. I've done a little experimenting
with some of these free reformatting tools, but none of them, that I am aware of,
give you the ability to precisely follow all the rules, though they come very close.
What tools do you recommend that can be used to take a source code file
and reformat it to precisely follow Sun's Java Code Conventions?
Other than TextPad, the only tool I used was Sun's DocCheck utility to discover any problems with my javadoc documentation. I highly recommend DocCheck. I concur with Mark that the best way to ensure good documentation is to do it as you go along. I also took a final pass through all the code fixing any indentation problems. Running DocCheck was a great way to find out about any javadoc problems. Also, actually reading the generated javadoc documentation was helpful in spotting some errors. Also, TextPad had a spell check facility that seemed to understand the format of Java comments so it located any misspellings in the Java comments.
Regards, George
SCJP, SCJD, SCWCD, SCBCD
Question 1
Section 3.1.1 says that all source files should begin with Beginning Comments
containing the class name, version information, data, and copyright notice.
George, since you scored 100, did you use Beginning Comments?
Question 2
Section 4, on indentation, states:
1. Four spaces should be used as the unit of indentation. The exact construction
of the indentation (spaces verse tabs) is unspecified.
2. Tabs must be set exactly every 8 spaces (not 4).
From item 1, if I have a tab equivalent to four spaces, then it seems that
I violate the condition in item 2. Is Sun basically saying that I must not use any
tabs in the source file, and only use spaces?
Question 3
It would make a lot of sense to use an automated tool to incorporate all the rules
in this document: Sun's Java Code Conventions. I've done a little experimenting
with some of these free reformatting tools, but none of them, that I am aware of,
give you the ability to precisely follow all the rules, though they come very close.
What tools do you recommend that can be used to take a source code file
and reformat it to precisely follow Sun's Java Code Conventions?
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Originally posted by Andrew Monkhouse:
I used CheckStyle to validate my coding in general, and Sun's DocCheck utility to check my documentation.
Regards, George
SCJP, SCJD, SCWCD, SCBCD
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
The first person to drink cow's milk. That started off as a dare from this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|