Results 1 to 7 of 7
- 01-27-2010, 03:37 AM #1
Member
- Join Date
- Jan 2010
- Posts
- 5
- Rep Power
- 0
-
No, most definitely not. Your goal should be to write code that is "self-commenting" where the variable and method names are so logical that they almost make it obvious what is going on. You should comment most methods, especially public ones, anything that may be confusing, and anything that your instructor says should be commented.
That sounds like code that should be refactored then. You might want to place the repeating bits into a method and then use loops as needed.Major portion of my code repeats the same thing over and over again.Last edited by Fubarable; 01-27-2010 at 03:57 AM.
- 01-27-2010, 04:21 AM #3
Member
- Join Date
- Jan 2010
- Posts
- 12
- Rep Power
- 0
What Fubarable is on point, but if actual commenting
is needed, then I'd suggest block commenting.. At the head of every code which is similar, have a comment saying what the function of that block of code does.Java Code://comment goes here
- 01-27-2010, 04:55 AM #4
Member
- Join Date
- Jan 2010
- Posts
- 5
- Rep Power
- 0
- 01-27-2010, 04:56 AM #5
Member
- Join Date
- Jan 2010
- Posts
- 5
- Rep Power
- 0
- 01-27-2010, 06:30 AM #6
Senior Member
- Join Date
- Oct 2009
- Location
- California,US
- Posts
- 201
- Rep Power
- 4
if it may help
non-javadoc commentsJava Code://comment 1
javadoc commentsJava Code:/* */
Java Code:/** */
- 01-27-2010, 09:26 AM #7
Moderator
- Join Date
- Apr 2009
- Posts
- 10,476
- Rep Power
- 16
I have a tendency to comment as part of the design (which goes back to the days when I had to do sequence diagrams). So a key method would look something like this before I even added any code to it:
The advantage (in my mind) is that you can see to turn each of those comments (bar the loop) into a call to another method, thus breakig up the work done by a single method, and you've also commented your thought processes which led you to write this in the way you have. I'm a firm believer on writing comments based on the fact the reader is going to be a bit thick...even that reader is going to be you in a few weeks time.Java Code:public void processSomething() { // First get the data. // loop over it. // call the thing. // call the other thing. // finally send data somewhere else. }
Similar Threads
-
How to generate comment or javadoc in java file ?
By Tonny in forum Advanced JavaReplies: 2Last Post: 01-03-2010, 05:49 PM -
How to strip out comment tags
By mr.vinnie in forum New To JavaReplies: 3Last Post: 09-30-2009, 02:12 AM -
URL/comment problem
By Chasingxsuns in forum New To JavaReplies: 4Last Post: 07-25-2009, 03:10 AM -
About Comment By Using SAX
By tapas in forum XMLReplies: 1Last Post: 01-24-2008, 05:29 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks