Questions about writing comments in code.

learn more… | top users | synonyms

3
votes
8answers
564 views

Do I Need To duplicate comments in Every File?

I have very similar code over multiple files in my project. If a client wanted some level of commented code, would I have to invest the time into duplicating the code for every file. I think it would ...
54
votes
17answers
3k views

Are first person comments distracting and unprofessional?

I just found myself writing the following comment in some (archaic Visual Basic 6.0) code I was writing: If WindowState <> 1 Then 'The form's not minimized, so we can resize it safely ...
1
vote
4answers
479 views

Does a prose to code compiler exist? [closed]

I have seen some horrible code in my time including people virtually duplicating the code in comments // add 4 to x x+=4; // for each i in 0 to 9 for (int i = 0; i < 10; i++) { // multiply x ...
1
vote
1answer
389 views

Metrics: Comments vs Documented API

I've been asked to run some code metrics in order to assess the quality of the code. One of the metrics was vaguely specified as "comments". I ran Sonar on my code, and while I got 10% on the ...
0
votes
4answers
187 views

Deciphering foreign code [duplicate]

What is the best strategy to go about understanding some one else's code for a medium sized project, if the code is not well documented and does not adhere to many coding standards?
2
votes
5answers
354 views

Run On Sentences in Technical Writing

This is just a question to think about. When you write technical documentation and programming comments, do you ever find yourself writing run-on sentences in order to be more precise? Is packing ...
4
votes
5answers
394 views

What is the right level of granularity for code commenting?

Commenting in code I believe is very important but recently I've been reviewing code that has left me wondering particular this one. //due to lack of confidence with web programming leaving this ...
5
votes
7answers
1k views

Is it wrong not to create Javadoc for my code?

I do a lot of Java programming at my work (I'm an intern) and I was wondering if it is generally a rule to create javadoc to accompany my code. I usually document every method and class anyways, but I ...
4
votes
3answers
576 views

How should one properly comment and license a set of code files before uploading to the public?

I've written a decent chunk of code over the past few days and I'm ready to git init it and push it to github. But before I do so, I want to do this the "correct" way in case anyone else wants to use ...
12
votes
8answers
2k views

Why do most programming languages not nest block comments?

A few do, but not any of the popular ones as far as I know. Is there something bad about nesting comments? I plan to have block comments nest in the (small) language I'm working on, but I would like ...
19
votes
9answers
4k views

Style and recommendations of commenting code

I want to hear from you any advice and experience of writing comments in your code. How do you write them in the most easy and informative way? What habits do you have when commenting parts of code? ...
2
votes
3answers
335 views

Where should I include comments in my “self-documenting code”?

I'm currently developing a web-app by myself and have made it a point to use descriptive variable and method names (sometimes at the expense of brevity) in order to minimize commenting. The plan was ...
8
votes
6answers
2k views

Is it necessary to write a javadoc comment for EVERY parameter in a method's signature?

One of the devs on my team believes that it is necessary to write a javadoc comment for EVERY parameter in a method's signature. I do not think this is necessary, and in fact I think it can even be ...
-1
votes
7answers
264 views

Single line comments for multiple indented lines of code [closed]

After many years of coding, trying various programming styles, weeding out unreadable or impractical stuff, I still can't figure out one thing: what is the best way to single-line-comment multiple ...
13
votes
9answers
557 views

Please share experience on how to make the source code easy for other to follow? [closed]

I can write source code in a period of time, but after a while of not touching the project, it takes me time to be familiar with the source code again. Also, other people need some time to study the ...
34
votes
12answers
2k views

Are outdated comments an urban myth?

I constantly see people making the claim that "comments tend to become outdated." The thing is, I think I have seen maybe two or three outdated comments my entire career. Outdated information in ...
3
votes
6answers
783 views

Should you use “internal abbreviations” in code comments?

Should you use "internal abbreviations/slang" inside comments, that is, abbreviations and slang people outside the project could have trouble understanding, for instance, using something like //NYI ...
22
votes
9answers
18k views

What does XXX mean in a comment? [closed]

What do people generally mean whenever you see XXX in a comment. Occasionally, I'll see a comment like this: # XXX - This widget really should frobulate the whatsit Of course, I can tell what the ...
6
votes
1answer
5k views

Header comment format

I realize that the "header comment" format varies from programmer to programmer, but what would be an example of a "good" header comment?
0
votes
4answers
182 views

Emphasize Some Comments - but not Dirty the Code

I'm having trouble structuring my comments at the moment. I have major sections of the code that, when scrolling through the document, I want to be able to see those stand out. Examples: This is ...
8
votes
11answers
2k views

Version control comments - past or present tense

For version control comments what do other users do/recommend - past or present tense? I.e. Changed x to be y. or Changing x to be y.
17
votes
11answers
1k views

“// …” comments at end of code block after } - good or bad?

I've often seen such comments be used: function foo() { ... } // foo while (...) { ... } // while if (...) { ... } // if and sometimes even as far as if (condition) { ... } // if ...
56
votes
24answers
5k views

Is writing comments inside methods not a good practice? [duplicate]

A friend told me that writing comments inside methods is not good. He said that we should have comments only for the method definitions(javadocs) but not inside the method body. It seems he read in a ...
22
votes
21answers
8k views

Self Documenting Code Vs. Commented Code

I had a search but didn't find what I was looking for, please feel free to link me if this question has already being asked. Earlier this month this post was made: ...
2
votes
3answers
325 views

How does one pluralize <see cref=“Notation”>'s?

What is the most appropriate way of writing this comment: /// <summary> /// Order - Identifies the ordinal location of this category /// relative to other listed categories. ...
17
votes
8answers
1k views

Are 'edited by' inline comments the norm in shops which use revision control?

The senior dev in our shop insists that whenever code is modified, the programmer responsible should add an inline comment stating what he did. These comments usually look like // YYYY-MM-DD <User ...
29
votes
13answers
5k views

Is commented out code really always bad? [duplicate]

Practically every text on code quality I've read agrees that commented out code is a bad thing. The usual example is that someone changed a line of code and left the old line there as a comment, ...
0
votes
2answers
154 views

How to systematize tagging in code? [closed]

There are several almost standard tags used in comments: FIXME, TODO, BUGBUG. Which other tags do you use and for what? Are there any standards on using them, i.e. format (supplementing with date ...
23
votes
3answers
16k views

What javadoc equivalents do you use in .net? [closed]

Java developers use Javadoc in order to write inline documentation in their comments. What are the alternatives for .net - specifically c# and VB.net that people actually use in real world projects?
14
votes
16answers
2k views

Would a language which doesn't allow comments yield more readable code? [closed]

Just out of curiosity, I started wondering whether a language which doesn't allow comments would yield more readable code as you would have be forced to write self-commenting code. Then again, you ...
8
votes
7answers
576 views

Commenting/In-Code Documentation Styles

This might be a stupid question, but it's been in the back of my head for a while and I can't find a decent answer anywhere else. I have a teacher who says we should explicitly list each parameter ...
4
votes
4answers
323 views

Correct alignment when outcommenting code

Suppose I have some code void some_block(void) { some_statement_1(); some_statement_2(); some_statement_3(); } Now I wish to out-comment statement #2, but here I never can find a way ...
6
votes
6answers
241 views

Divisional/Sectional comments, good or bad?

I know the general trend against comments explaining how something works, and how it's a good idea to use them only to explain why you're doing what you're doing, but what about using comments as a ...
7
votes
9answers
1k views

What are your thoughts on Periods/Full Stops in code comments? [closed]

I saw this asked in the SO Tavern, so I'm posting the question here. I thought it an interesting question. (Of course it doesn't belong on SO, but I think it's OK here.) Do you add periods (or, as ...
10
votes
6answers
768 views

<!— open --> Why do so many developers do this in their HTML? <!— /close -->

<body> <!-- wrapper --> <div id="wrapper"> <!-- title --> <div id="title"><img src="title.png" alt="" /></div> <!-- form wrapper --> ...
4
votes
6answers
2k views

What should I include in my class documentation header

I'm looking for informative class documentation format for my Entity, Business Logic and Data Access classes. I found following two formats from here Format 1 ...
40
votes
14answers
7k views

Why are /// comment blocks important?

Someone once said we should prefix all our methods with the /// <summary> comment blocks (C#) and I am wondering if that is true or not. I started to use them and found they annoyed me quite a ...
11
votes
5answers
253 views

Is it OK to put a link to Q&A sites in a program's comments?

In quite some codebase you can see comments stating things like: // Workaround for defect 'xxx', (See bug 1434594 on Sun's bugparade) So I've got a few questions, but they're all related. Is it ...